Javascript Parse/evaluation Order?
This is probably a nub question, but I don't understand why this works: This alerts 'f
Solution 1:
JavaScript, like PHP, tracks top-level function
declarations before the code runs.
However, you can bypass the auto-function by using assignments:
var a = function a() { }
Solution 2:
A must read about the types of function definitions in JavaScript.
Solution 3:
Function declarations are hoisted to the top, and therefore declared first and foremost.
You can change this behavior by assigning them to a variable like so
var a = function() {
// do it
};
This assigns the variable a
to an anonymous function.
Post a Comment for "Javascript Parse/evaluation Order?"