Skip to content

Latest commit

 

History

History
16 lines (9 loc) · 449 Bytes

hoisting.md

File metadata and controls

16 lines (9 loc) · 449 Bytes

Hoisting

Hoisting is JavaScript's default behavior of moving declarations to the top.

In JavaScript, Declearations are hoisted not initilisations

Ex:

var x = 5; // Initialize x

elem = document.getElementById("demo"); // Find an element elem.innerHTML = x + " " + y; // Display x and y

var y = 7; // Initialize y

Here y is undefined, thats because only the declaration (var y), not the initialisation (=7) is hoisted to the top.