DEV Community

ana
ana

Posted on

java script Hoisting

Image description

HI!
in this article i want explain Hoist and Hoisting rule in java script. as you know javaScript its a language with a lot concept and rules and tips. so Hoisting its another rule of variable in javaScript, so important and for your programming way it can be so good and helpful.

Hoisting is about Declaration and this things.
there is some way for declare and use and display a variable and value of that variable.
for example:

x = 1;
console.log(x);
var x;
Enter fullscreen mode Exit fullscreen mode

maybe after this you say with yourself main rule for declare a variable is this:

var x = 1;
Enter fullscreen mode Exit fullscreen mode

yes, in general we declare with this rule and syntax but if we use from those syntax we use from Hoist rule in our program.
but believe me Hoist its can be useful and helpful, every rules in javaScript is so helpful and good for our way.

Tip/ we can't use const or let keyword for above example, this will result in a ReferenceError.

Top comments (0)