4 ms·
There aren't, the name of a function is optional (if you assign it to a variable.) So you can write: function a() {} // or var a = function() {}
by ripter 12y ago
There aren't, the name of a function is optional (if you assign it to a variable.) So you can write:
function a() {}
// or
var a = function() {}
// or
var a = function a() {}
// or
obj.prototype.a = function() {}
// or
obj.prototype.a = function a() {}
There is little difference in the function declaration. The difference is if you named it or not.
The reason you have to be careful with the var a = function() {} forms is because variables are hoisted. So while the function will exist, your variable will not point to that function until the assignment happens.