I am reading a great book named "Secrets of the JavaScript Ninja" written by John Resig & Bear Bibeaoult. In chapter 3.2, it gives an example;
var canFly = function(){ return true; };
Then it says;
An anonymous function is created and assigned to a global variable named canFly. Because of JavaScript's functional nature, the function can be invoked through this reference as canFly(). In this respect, it's almost functionally equivalent to declaring a named function named "canFly", but not quite. One major difference is that the function's name property is "", not "canFly".
But when I try to execute the example on Chrome's Developer Tools and inspect the name
property of the canFly
function, it returns the value "canFly" instead of an empty string.
canFly.name;
// > "canFly"
Did anonymous functions assigned to variables have no names in the earlier days? If so, what has changed? Or did the authors make a mistake?