DEV Community

Discussion on: javascript question - Hoisting

Collapse
 
sanjeevpanday profile image
sanjeev

Hoisting is applicable to variables as well.

Both variables and functions are put into memory during context creation ( or compile ) phase.

Variables declared with var keyword will get initialized with value undefined during context creation phase.

So you would not get error for first console.log(a)