package
Polyfill for the basic functionality of `Function.name` accessor property in its pre-ES6 form
npm install function.name-polyfillGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
6.6 kB
Includes dependencies.
Function.nameA polyfill for the basic functionality of Function.name accessor property in its pre-ES6 form.
function hello() {
/* ... */
}
console.log(hello.name); // "hello"var fn = function foo() {
/* ... */
};
console.log(fn.name); // "foo"Most modern browsers have already supported this basic functionality for quite some time but this polyfill will apply to at least the following:
>=9 <12<33For IE <9, you can still use fn._name() instead.
name accessor property can provide you with the name of a named function definition (either a named function declaration or a named function expression).name accessor property is also intentionally marked as configurable.<5<5, the accessor property will be configurable (expected) AND enumerable (unexpected) due to having to implement it using Object.prototype.__defineGetter__ instead of Object.defineProperty.