DOM and Javascript – Test 1

Test level: Beginner – Mid-Intermediate

Test time: (max) 30 minute

Questions:

1. Explain DOM bubbling and capture.

2. What is the difference between ‘==’ and ‘===’ ? (classic JavaScript question)

3. What does “1”+5+2 evaluate to? What about 6 + 3 + “8”?

4. What is the difference between ‘undefined’ value and ‘null’ value?

5. Difference between ‘window.onload’ and ‘document.onload’? What about the ‘onDocumentReady’ (‘DOMContentLoaded’)?

6. What are Javascript closures ?When would you use them?

7. What is the difference between:

1. 
<button id="myButton" onclick="alert('hello!');"> Say Hello! </button>

2. 
document.getElementById('myButton').onclick = function(){
    alert('Hello!');
}

3. 
var el = document.getElementById('myButton')
el.addEventListener( 'click', function(){
     alert('Hello!');
}, false);

8. What is Javascript namespacing? Why and where would you use it?

9. How would you alert the string ‘foobar’ after a 10 second delay. (simple yet effective task)

10. What’s the difference between these two statements:

var x = 5;
x = 5;