January 2020
Intermediate to advanced
470 pages
11h 13m
English
The concept of first-class objects means that functions can be created, assigned, changed, passed as parameters, and returned as a result of yet other functions in the very same way that you can with, say, numbers or strings. Let's start with its definition. Let's look at how you usually define a function:
function xyzzy(...) { ... }
This is (almost) equivalent to writing the following:
var xyzzy = function(...) { ... }
However, this is not true for hoisting. In this case, JavaScript moves all definitions to the top of the current scope, but does not move the assignments; so, with the first definition you can invoke xyzzy(...) from any place in your code, but with the second, you cannot invoke the function until the assignment ...
Read now
Unlock full access