1. What is the difference between the following 2 statements?

setTimeout(booyah, 2000);

setTimeout(booyah(), 2000)

Answer:
The first one wait until 2000 milisecond to print out "booyah" to console while the second one is the wrong way to use with setTimeout because of parenthesis"()" so that it prints out immediately without waiting 2000 milisecond.

2. What do the following 2 alerts display (answer without running the code)?

var myfunc = function(a, x) {
return a * x;
};
var x = myfunc(2, 3);
var y = myfunc;
alert(x);
alert(y(2,3));
Answer:
Both Alerts display same results which are 6.

3. Write functions booyah1 and booyah2 so that in both cases below, an alert box comes up after 2 seconds that says “BOOYAH!”

setTimeout(booyah1, 2000);
setTimeout(booyah2(), 2000);
Answer:
Click on each button.

4. What is "Unobtrusive Javascript"? What is the practical application of Unobtrusive Javascript (and the reasons for using it)?

Answer:
It is the separation of content (HTML) and behavior (Javascript).
The practical application of Unobtrusive Javascript should contains 3 major categories:
  • content (HTML)
  • presentation (CSS)
  • behavior (JavaScript)

This approach is useful in so many ways as it makes our code less error prone, clean, easy to update and to debug.