- Posted On 20 October 2016
- In Programming
Lets first see what the word "Hoisting" means in general. If you type "define:hoisting" in the google, it will show you the dictionary meaning of the word "Hoist", which will also show the synonyms of this word which are "raise, raise up, lift, lift up, haul up, heave up, jack up, hike up, winch up, pull up, upraise, uplift, elevate etc" and example is also self explainatory i.e. "a white flag was hoisted".
So by meaning you are clear that in hoisting something is getting raised or pulled up at top.
Try running following code in console.
a=10; alert(a); var a;
In hoisting, all the variable declartion and function definations gets moved at top, and point to remember here is, when we say moved at top its not gets moved physically in actual. What does happen is the variable and function declarations are put into memory during the compile phase, but stays exactly where you typed it in your coding.
Above code will interpreted like following after hoisting.
var a; a=10; alert(10);
Hope the concept is more clear to you now.
Below is the summary points related to "Hoisting",
- All variable declarations and function definations gets hoisted (not gets physically moved at top, rather put into memory)
- "use strict" has no impact on hoisting(check this link answer on stackoverflow)
- In function expression, only declaration part is gets hoisted so the sequence matters, on the other hand, function definitions gets hoisted as a full.
That's it from my side, if you have anything to add, you can share it in comment section below. Thanks. Do share this post with your friends if you liked it.
Typewriter - Automatic TypeScript Template generation from C# classes in Visual Studio
Typewriter, an extension for visual studio that generates TypeScript files from C# code files using TypeScript templates. Convert your C# model classes to TypeScript automatically.
Assembla - Free and private repository to manage your source code online with SVN subversion hosting
With Assembla you can share source code with others online. Free & Private source code repository with SVN Subversion, Git & Perforce Hosting.
Swagger - Powerful Opensource Framework for RESTful API
With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. Swagger Editor allows you to generate code, documentation with ease.
How to call click or any event only once in jQuery
Know how to execute an click event or any event only once for any element in jQuery. Perform action only once and even not required to unbind event.
Top 10 Visual Studio things which can boost developers coding speed
Visual Studio 2012 provides some coding features by which you can code faster if use them properly. This post will cover top 10 things among them to boost your development speed.