DEV Community

Discussion on: Hoisting in Javascript(Part 1)

Collapse
z00md profile image
z00md

Just to add - Function declarations take priority over var declarations

console.log(myVal); // function and not undefined
var myVal = 11;
function myVal() {}
var myVal = 22;
Enter fullscreen mode Exit fullscreen mode

Point to note that after line 1 myVal will have 11 and 22 because of reassignments.

Collapse
prashan81992916 profile image
prashanth Author • Edited on

Yeah that's true. To continue on this, none of these redeclarations are not possible for let and const because of their strict nature.