DEV Community

Discussion on: Hoisting in Javascript(Part 1)

z00md profile image

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.

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.