What is being done in the following JavaScript code? [code] <script> if (window.attachEvent) window.attachEvent('onload', fetch); else window.ad

Tâm Tây

New member
What is being done in the following JavaScript code?
Code:
<script>
if (window.attachEvent)
window.attachEvent('onload', fetch);
else
window.addEventListener('load', fetch, false);
</script>
A. Event and EventListener is created according to the if-else
B. The values are updated
C. The value is called
D. The values are stored
 
Answer: a
Explanation: In the above code, the event is attached with onload and the fetch function is called. Also, the event listener is created and added if the “if” fails and is stored as load and the fetch function is called.
 

Tìm kiếm

Back
Top