3 ms·
Its called function hoisting. Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting https://developer.mozilla.org/e
by subbu 12y ago
Its called function hoisting. Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- moron4hire 12y agoAlso, the latter syntax names the function for the stack frame, which is useful for debugging. You will sometimes see MyClass.prototype.myFunc = function myFunc_(){}, because otherwise myFunc is only an anonymous function assigned to a property on the prototype object. And the trailing underscore is to placate some version of IE. Or something. I can't keep it all strait when I'm just out of bed.
- thedufer 12y agoThat double-naming thing is going out of fashion, since modern browsers + node.js all know how to figure out function names without it.
- deleted 12y ago[deleted]