javascript - What's the difference between those two function definition? -


1 style

var x = function(xx) { } 

another

x : function (xx) { } 

what's difference between 2 styles

in first case, result of evaluating function expression (i.e. resulting function — evaluation not calling) assigned variable.

in second case, start label , have syntax error.

you meant:

var foo = {     x : function (xx) {     } } 

object literal function assigned property of new object instead of variable.


Comments