1. function.name-polyfill
Polyfill for the basic functionality of `Function.name` accessor property in its pre-ES6 form
function.name-polyfill
Package: function.name-polyfill
Created by: JamesMGreene
Last modified: Sat, 18 Jun 2022 04:16:01 GMT
Version: 1.0.6
License: MIT
Downloads: 327,091
Repository: https://github.com/JamesMGreene/Function.name

Install

npm install function.name-polyfill
yarn add function.name-polyfill

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code