# array-includes

> An ES7/ES2016 spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.

Latest version **3.2.0** (published 2026-09-09) · MIT license · 0 weekly downloads

> **Native alternative:** Array.prototype.includes — Use native JavaScript (Node 6.0.0+) (https://developer.mozilla.orgGlobal_Objects/Array/includes)

## Install

```sh
npm install array-includes
pnpm add array-includes
yarn add array-includes
bun add array-includes
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2026-09-09 |
| First published | 2015-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 8 |
| Unpacked size | 30.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | Array.prototype.includes, includes, array, ES7, shim, polyfill, contains, Array.prototype.contains, es-shim API |

## Links

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

## Dependencies (8)

- [call-bind](https://npm.io/package/call-bind.md) ^1.0.9
- [is-string](https://npm.io/package/is-string.md) ^1.1.1
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.4
- [es-abstract](https://npm.io/package/es-abstract.md) ^1.24.2
- [es-object-atoms](https://npm.io/package/es-object-atoms.md) ^1.1.2
- [math-intrinsics](https://npm.io/package/math-intrinsics.md) ^1.1.0
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1
- [es-shim-unscopables](https://npm.io/package/es-shim-unscopables.md) ^1.1.0

## Recent versions

- 3.2.0 (latest) — 2026-09-09
- 3.1.9 — 2025-06-02
- 3.1.8 — 2024-03-20
- 3.1.7 — 2023-09-03
- 3.1.6 — 2022-11-08
- 3.1.5 — 2022-05-03
- 3.1.4 — 2021-10-05
- 3.1.3 — 2021-02-20
- 3.1.2 — 2020-11-25
- 3.1.1 — 2019-12-21
- 3.1.0 — 2019-12-12
- 3.0.3 — 2017-04-19
- 3.0.2 — 2016-02-06
- 3.0.1 — 2015-08-16
- 3.0.0 — 2015-08-16
- … 10 more at https://npm.io/package/array-includes/versions

## README

# array-includes <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 ES7/ES2016 spec-compliant `Array.prototype.includes` shim/polyfill/replacement that works as far down as ES3.

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 proposed [spec](https://262.ecma-international.org/6.0/).

Because `Array.prototype.includes` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.

Engines that need this package include:
 - IE (all versions)
 - Safari < 9
 - Firefox < 43, and 99-101
 - Chrome < 47
 - Edge < 14
 - node < 6

## Getting started

```sh
npm install --save array-includes
```

## Usage

Basic usage: **includes(array, value[, fromIndex=0])**

```js
var includes = require('array-includes');
var assert = require('assert');
var arr = [ 'one', 'two' ];

includes(arr, 'one'); // true
includes(arr, 'three'); // false
includes(arr, 'one', 1); // false
```



## Example

```js
var arr = [
	1,
	'foo',
	NaN,
	-0
];

assert.equal(arr.indexOf(0) > -1, true);
assert.equal(arr.indexOf(-0) > -1, true);
assert.equal(includes(arr, 0), true);
assert.equal(includes(arr, -0), true);

assert.equal(arr.indexOf(NaN) > -1, false);
assert.equal(includes(arr, NaN), true);

assert.equal(includes(arr, 'foo', 0), true);
assert.equal(includes(arr, 'foo', 1), true);
assert.equal(includes(arr, 'foo', 2), false);
```

```js
/* when Array#includes is not present */
delete Array.prototype.includes;
var shimmedIncludes = includes.shim();

assert.equal(shimmedIncludes, includes.getPolyfill());
assert.equal(arr.includes('foo', 1), includes(arr, 'foo', 1));
```

```js
/* when Array#includes is present */
var shimmedIncludes = includes.shim();

assert.equal(shimmedIncludes, Array.prototype.includes);
assert.equal(arr.includes(1, 'foo'), includes(arr, 1, 'foo'));
```

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

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

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