3

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

Community
  • 1
  • 1
m4tx
  • 4,139
  • 5
  • 37
  • 61

3 Answers3

4

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)?

Community
  • 1
  • 1
LPD
  • 2,833
  • 2
  • 29
  • 48
4

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
  }
};
amrfaissal
  • 1,060
  • 1
  • 7
  • 18
0

No, it’s the quite the same thing for each of them.

phaazon
  • 1,972
  • 15
  • 21