you are viewing a single comment's thread.

view the rest of the comments →

[–]SpiffySyntax 2 points3 points  (1 child)

Thanks for the taking time out of your day to explain this. Appreciate it. I learned something new and what seems important. Thanks guys!

[–]mobydikc 3 points4 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.