Created
December 6, 2017 11:35
-
-
Save abel-masila/5f91666dba3a10ce76d972b421883344 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Hoisting | |
| y = 80; // Assign 5 to x | |
| x=y+5 // sum up 5 with the value of y | |
| var y; // Declare y | |
| //JavaScript only hoists declarations, not initializations. | |
| var name = "Abel"; | |
| (function () { | |
| // Outputs: "Original name was undefined" | |
| console.log("Original name was " + name); | |
| var name = "Multithread"; | |
| // Outputs: "New name is Underhill" | |
| console.log("New name is " + name); | |
| })(); | |
| //function hoisting | |
| // Outputs: "Yes!" | |
| isItHoisted(); | |
| function isItHoisted() { | |
| console.log("Yes!"); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment