Polyfill for ECMAScript 6's `Function.name`.
Clone or download
JamesMGreene v1.0.6
Support function declarations with block comments between the `function` keyword and function name

Fixes #6
Latest commit 58b314d May 15, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Aug 22, 2014
.npmignore v1.0.0 Jul 18, 2016
.travis.yml v1.0.6 May 16, 2018
Function.name.js v1.0.6 May 16, 2018
LICENSE v1.0.6 May 16, 2018
README.md Nah... make it configurable again Oct 24, 2016
package.json v1.0.6 May 16, 2018

README.md

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:

  • IE >=9 <12
  • Chrome <33

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

Caveats

Pre-ES6 Form

  • In short, this means that this polyfilled name accessor property can provide you with the name of a named function definition (either a named function declaration or a named function expression).
  • Unlike other browsers with a similar support level for the pre-ES6 form, this poyfilled name accessor property is also intentionally marked as configurable.

Chrome <5

Other Documentation