October 2018
Intermediate to advanced
590 pages
15h 5m
English
This is another thing that Java developers usually easily get confused. Hoisting is a metaphor for the way that JavaScript interpreters will lift function declarations and variable declarations to the top of their containing scope. So, In JavaScript, you can see something that is obviously wrong and will definitely break the compilation if you write that in Java, but it is totally valid in JavaScript.
Let’s see an example:
1. travel = 'No plan';2. var travel;3. console.log(travel); // Is the output: undefined? 4.5. function travel() {6. console.log('Traveling');7. }8. travel(); // Is the output: Traveling?
What will the output be when the JavaScript engine executes line 3 and 8? It is not undefined, and not Traveling. Line 3 is ...
Read now
Unlock full access