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
-
Please refer to this thread : stackoverflow.com/questions/1866084/…amrfaissal– amrfaissal2012年12月12日 14:11:11 +00:00Commented Dec 12, 2012 at 14:11
3 Answers 3
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
}
};
Comments
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)?
6 Comments
No, it’s the quite the same thing for each of them.