# function.prototype.name

> An ES2015 spec-compliant `Function.prototype.name` shim

Latest version **1.2.0** (published 2026-06-11) · MIT license · 0 weekly downloads

> **Native alternative:** Use functions `.name` property — Use native JavaScript (Node 0.10.0+) (https://developer.mozilla.orgGlobal_Objects/Function/name)

## Install

```sh
npm install function.prototype.name
pnpm add function.prototype.name
yarn add function.prototype.name
bun add function.prototype.name
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2026-06-11 |
| First published | 2016-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 9 |
| Unpacked size | 29.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | Function.prototype.name, function, name, ES6, ES2015, shim, polyfill, es-shim API |

## Links

- npm: https://www.npmjs.com/package/function.prototype.name
- Repository: https://github.com/es-shims/Function.prototype.name
- Homepage: https://github.com/es-shims/Function.prototype.name#readme
- Issues: https://github.com/es-shims/Function.prototype.name/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/function.prototype.name

## Dependencies (9)

- [hasown](https://npm.io/package/hasown.md) ^2.0.4
- [call-bind](https://npm.io/package/call-bind.md) ^1.0.9
- [es-errors](https://npm.io/package/es-errors.md) ^1.3.0
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.4
- [is-callable](https://npm.io/package/is-callable.md) ^1.2.7
- [is-document.all](https://npm.io/package/is-document.all.md) ^1.0.0
- [es-define-property](https://npm.io/package/es-define-property.md) ^1.0.1
- [functions-have-names](https://npm.io/package/functions-have-names.md) ^1.2.3
- [has-property-descriptors](https://npm.io/package/has-property-descriptors.md) ^1.0.2

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2026-06-11
- 1.1.8 — 2024-12-20
- 1.1.7 — 2024-12-15
- 1.1.6 — 2023-08-28
- 1.1.5 — 2021-10-02
- 1.1.4 — 2021-02-22
- 1.1.3 — 2020-11-28
- 1.1.2 — 2019-12-15
- 1.1.1 — 2019-07-24
- 1.1.0 — 2017-12-31
- 1.0.3 — 2017-07-21
- 1.0.2 — 2017-07-14
- 1.0.1 — 2017-07-12
- 1.0.0 — 2016-02-27

## README

# function.prototype.name <sup>[![Version Badge][2]][1]</sup>

[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][11]][1]

An ES2015 spec-compliant `Function.prototype.name` shim. Invoke its "shim" method to shim Function.prototype.name if it is unavailable.
*Note*: `Function#name` requires a true ES5 environment - specifically, one with ES5 getters.

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags).

Most common usage:

## Example

```js
var functionName = require('function.prototype.name');
var assert = require('assert');

assert.equal(functionName(function foo() {}), 'foo');

functionName.shim();
assert.equal(function foo() {}.name, 'foo');
```

## Supported engines
Automatically tested in every minor version of node.

Manually tested in:
  - Safari: v4 - v15 <sub>(4, 5, 5.1, 6.0.5, 6.2, 7.1, 8, 9.1.3, 10.1.2, 11.1.2, 12.1, 13.1.2, 14.1.2, 15.3, 15.6.1)</sub>
  - Chrome: v15 - v81, v83 - v106<sub>(every integer version)</sub>
    - Note: This includes Edge v80+ and Opera v15+, which matches Chrome
  - Firefox: v3, v3.6, v4 - v105 <sub>(every integer version)</sub>
    - Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function
    - Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function`
  - IE: v6 - v11<sub>(every integer version</sub>
  - Opera: v11.1, v11.5, v11.6, v12.0, v12.1, v12.14, v12.15, v12.16, v15+ <sub>v15+ matches Chrome</sub>

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[1]: https://npmjs.org/package/function.prototype.name
[2]: https://versionbadg.es/es-shims/Function.prototype.name.svg
[5]: https://david-dm.org/es-shims/Function.prototype.name.svg
[6]: https://david-dm.org/es-shims/Function.prototype.name
[7]: https://david-dm.org/es-shims/Function.prototype.name/dev-status.svg
[8]: https://david-dm.org/es-shims/Function.prototype.name#info=devDependencies
[11]: https://nodei.co/npm/function.prototype.name.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/function.prototype.name.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/function.prototype.name.svg
[downloads-url]: https://npm-stat.com/charts.html?package=function.prototype.name

---
_Source: https://npm.io/package/function.prototype.name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
