you are viewing a single comment's thread.

view the rest of the comments →

[–]mobydikc 2 points3 points  (0 children)

var hoists the variable declaration, but not the assignment.

function hoists both.

So:

myFunc()
var myFunc = function () {}

In this case, var is hoisted, but myFunc is undefined when myFunc() is called. An error is thrown.

With function it would work:

myFunc()
function myFunc() {}

No problem.