Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution.
Hoisting is JavaScript’s default behavior of moving declarations to the top.
In JavaScript, a variable can be declared after it has been used. In other words; a variable can be used before it has been declared.
result => 5
result => 5
To understand this, you have to understand the term “hoisting”.
Hoisting is JavaScript’s default behavior of moving all declarations to the top of the current scope (to the top of the current script or the current function).
#software-engineering #front-end-development #hoisting #javascript