3. Anonymous function
function() {
}
-- A function without a name is called an anonymous
function!
BUT the above code won’t work... yet
4. Functions in JS
Functions in JavaScript are first-class objects. It means
that, any functions in JS can be treated like an object!
So… what does it actually mean? What is the advantage?
5. function sayHello() {
return "Hello World";
}
sayHello();
The advantage
can be called as
(sayHello)();
10. (function() {
return "Hello World";
})();
Now, it’s an anonymous function! The double parenthesis
at the end of the function declaration will immediately call
the function just as you would do with:
(sayHello)();
The refactored code