Hoisting, when in JavaScript variable used before declaration that is called hoisting, a variable can be declared after it has been used.

In other words; you can say one variable can be used before it has been declared.

example

a = 10; // Assign 10 to a variable
elem = document.getElementById(“test”); // Find an element
elem.innerHTML = a; // Display a in the element

var a; // Declare a

example

var a; // Declare a variable
x = 10; // Assign 10 to a

elem = document.getElementById(“test”); // Find an element
elem.innerHTML = a; // Display a in the element

News Reporter

Leave a Reply

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

*

code