I'm reading this tutorial: http://nathansjslessons.appspot.com/
Inside there's a lessons that says:
// A simple function that adds one
var plusOne = function (x) {
return x + 1;
};
I'm used to see functions like this:
function myFunction() {
return x + 1;
};
What's the difference between the first and the second?
The only difference is the first function:
var plusOne = function (x) { return x + 1; };
is defined at runtime, whereas another function:
function myFunction() { return x + 1; };
is defined at parse time for the script block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With