created by Brian Leroux & Andrew Lunny. sparodically uncurated by David Trejo.

magic function properties

    var f = function() { }; = 'foo'; // sets to 'foo'

Functions are objects, so you can set properties on them after creation.; // is '' = 'foo';; // is still ''

But not all the time.

    var f = function myFunction() { };; // is 'myFunction'

Functions happen to have magic properties. One of them is the non-standard .name, which stores the function's first name and read-only.


Fork me on GitHub