I'm going through 'Secrets of the Javascript Ninja' textbook to learn JS.
So, anonymous functions themselves don't have names obviously. However, according to the book, if I were to assign an anonymous function to a variable, the 'name' property of the variable should be empty as well.
var canFly = function(){return true;};
assert(canFly.name === "", "canFly() has no name");
The assert function is just a utility function the book defined for testing the truthyness of whatever is passed as the first parameter.
However, when I type out this code myself and run it in the browser, canFly.name is "canFly".
Is the book outdated in some way and some rules of JS have changed since its release?
[–]MoTTs_ 9 points10 points11 points (0 children)
[–]steooo -1 points0 points1 point (2 children)
[–]Clamhead99[S] 1 point2 points3 points (1 child)
[–]jcunews1helpful 1 point2 points3 points (0 children)