Possible Duplicate:
JavaScript: var functionName = function() {} vs function functionName() {}
What’s the difference in those declarations (in JavaScript)?
Is there any differences between the following function declarations:
function wtf() {
}
lol = function() {
}
omg: function() {
}
?
Regards
1- Is a regular function declaration.
2- You declare an anonymous function and you store it in a variable.
3- The last one is part of an object notation :
var obj = {
omg:function(value){
// some code here
}
};
1st one :
creates a function at page level ( global level u can say )
2nd : Assings the function to variable 'lol'
3rd: Syntax error. :P
Exactly similar to: What's the difference in those declarations (in JavaScript)?
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