Hoisting (JavaScript)
Resources
- https://www.w3schools.com/js/js_hoisting.asp
- https://dev.to/aparna_joshi_/javascript-scope-and-hoisting-understanding-block-scope-503g
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.
x = 5; // Assign 5 to x
elem = document.getElementById("demo"); // Find an element
elem.innerHTML = x; // Display x in the element
var x; // Declare x