JavaScript Hoisting

In JavaScript, hoisting is the behavior of moving declarations to the top of their scope. This means that variable and function declarations are processed before any code is executed, regardless of where the declaration is written in the code

example code:

output: hii

Only global variable get hoisted. The let and const keywords were introduced in ECMAScript 6 to provide block-scoped declarations. Unlike variables declared with var, variables declared with let and const are not hoisted to the top of their scope

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top