A Little-known Fact About JavaScript Hoisting

added by JavaScript Kicks
8/14/2018 7:28:55 AM

470 Views

At some point when reading about scope in JavaScript, you may have come across the term hoisting. It's often used in the context of variable or function definitions. For example, consider the following code: doSomething(); for (i = 0; i <= 10; i++) { console.log(i); } function doSomething() { console.log('function executed'); } View on JS Bin Although the doSomething() function is called before it's defined, the code still works.


0 comments