I don't think hoisting applies to vars, so the first console.log(a) should cause an error to be thrown as "a" doesn't exist yet.
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)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't think hoisting applies to vars, so the first console.log(a) should cause an error to be thrown as "a" doesn't exist yet.
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)