# object.getprototypeof

> An ES5 mostly-spec-compliant `Object.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible

Latest version **1.0.7** (published 2025-01-03) · MIT license · 0 weekly downloads

> **Native alternative:** Object.getPrototypeOf — Use native JavaScript (Node 0.10.0+) (https://developer.mozilla.orgGlobal_Objects/Object/getPrototypeOf)

## Install

```sh
npm install object.getprototypeof
pnpm add object.getprototypeof
yarn add object.getprototypeof
bun add object.getprototypeof
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2025-01-03 |
| First published | 2021-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 5 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | Object.getPrototypeOf, proto, __proto__, [[Prototype]], getPrototypeOf, ES5, shim, polyfill, es-shim API, browser |

## Links

- npm: https://www.npmjs.com/package/object.getprototypeof
- Repository: https://github.com/es-shims/Object.getPrototypeOf
- Issues: https://github.com/es-shims/Object.getPrototypeOf/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/object.getprototypeof

## Dependencies (5)

- [call-bind](https://npm.io/package/call-bind.md) ^1.0.8
- [get-proto](https://npm.io/package/get-proto.md) ^1.0.1
- [es-object-atoms](https://npm.io/package/es-object-atoms.md) ^1.0.0
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1
- [reflect.getprototypeof](https://npm.io/package/reflect.getprototypeof.md) ^1.0.10

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2025-01-03
- 1.0.6 — 2024-03-17
- 1.0.5 — 2023-09-07
- 1.0.4 — 2022-11-07
- 1.0.3 — 2021-10-04
- 1.0.2 — 2021-09-08
- 1.0.1 — 2021-01-13
- 1.0.0 — 2021-01-12

## README

# object.getprototypeof <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

An ES5 mostly-spec-compliant `Object.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible - specifically, anything with `__proto__` support, or ES6. Built-in types will also work correctly in older engines.

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/5.1/).

## Example

```js
var getPrototypeOf = require('object.getprototypeof');
var assert = require('assert');

assert.equal(getPrototypeOf(true), Boolean.prototype);
assert.equal(getPrototypeOf(42), Number.prototype);
assert.equal(getPrototypeOf(''), String.prototype);
assert.equal(getPrototypeOf(/a/g), RegExp.prototype);
assert.equal(getPrototypeOf(new Date()), Date.prototype);
assert.equal(getPrototypeOf(function () {}), Function.prototype);
assert.equal(getPrototypeOf([]), Array.prototype);
assert.equal(getPrototypeOf({}), Object.prototype);
```

```js
var getPrototypeOf = require('object.getprototypeof');
var assert = require('assert');
/* when Object.getPrototypeOf is not present */
delete Object.getPrototypeOf;
var shimmed = getPrototypeOf.shim();
assert.equal(shimmed, getPrototypeOf.getPolyfill());

assert.equal(Object.getPrototypeOf(true), Boolean.prototype);
assert.equal(Object.getPrototypeOf(42), Number.prototype);
assert.equal(Object.getPrototypeOf(''), String.prototype);
assert.equal(Object.getPrototypeOf(/a/g), RegExp.prototype);
assert.equal(Object.getPrototypeOf(new Date()), Date.prototype);
assert.equal(Object.getPrototypeOf(function () {}), Function.prototype);
assert.equal(Object.getPrototypeOf([]), Array.prototype);
assert.equal(Object.getPrototypeOf({}), Object.prototype);
```

```js
var getPrototypeOf = require('object.getprototypeof');
var assert = require('assert');
/* when Object.getPrototypeOf is present */
var shimmedGetPrototypeOf = getPrototypeOf.shim();
assert.equal(shimmedGetPrototypeOf, Object.getPrototypeOf);
assert.equal(Object.getPrototypeOf([]), Array.prototype);
```

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

[package-url]: https://npmjs.org/package/object.getprototypeof
[npm-version-svg]: https://versionbadg.es/es-shims/Object.getPrototypeOf.svg
[deps-svg]: https://david-dm.org/es-shims/Object.getPrototypeOf.svg
[deps-url]: https://david-dm.org/es-shims/Object.getPrototypeOf
[dev-deps-svg]: https://david-dm.org/es-shims/Object.getPrototypeOf/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/Object.getPrototypeOf#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/object.getprototypeof.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/object.getprototypeof.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/object.getprototypeof.svg
[downloads-url]: https://npm-stat.com/charts.html?package=object.getprototypeof
[codecov-image]: https://codecov.io/gh/es-shims/Object.getPrototypeOf/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/es-shims/Object.getPrototypeOf/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Object.getPrototypeOf
[actions-url]: https://github.com/es-shims/Object.getPrototypeOf/actions

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