I always used to write functions like this:
var myFunction = function(param) {
console.log(param);
};
myFunction('myFunction');
Now I've seen this:
var otherFunction = function whyNameHere(param) {
console.log(param);
};
otherFunction('otherFunction');
and I'm wondering what is whyNameHere
? When and why should functions be written like this? Also I can call it exactly the same as the myFunction
function above.. why should someone write whyNameHere
? Also is there a naming for this kind of function?
If anyone wants to play with it, here is a fiddle