GitHub - JamesMGreene/Function.name: Polyfill for ECMAScript 6's Function.name. (original) (raw)

Function.name

Overview

A polyfill for the basic functionality of Function.name accessor property in its pre-ES6 form.

Usage

Named function declarations

function hello() { /* ... */ } console.log(hello.name); // "hello"

Named function expressions

var fn = function foo() { /* ... */ }; console.log(fn.name); // "foo"

Browser Compatibility

Most modern browsers have already supported this basic functionality for quite some time but this polyfill will apply to at least the following:

For IE <9, you can still use fn._name() instead.

Caveats

Pre-ES6 Form

Chrome <5

Other Documentation