# array-includes

[![Build Status](https://travis-ci.org/es-shims/array-includes.svg)](https://travis-ci.org/es-shims/array-includes) [![dependency status](https://david-dm.org/es-shims/array-includes.svg)](https://david-dm.org/es-shims/array-includes) [![dev dependency status](https://david-dm.org/es-shims/array-includes/dev-status.svg)](https://david-dm.org/es-shims/array-includes#info=devDependencies) [![License](http://img.shields.io/npm/l/array-includes.svg)](https://github.com/bgoonz/Learning-Redux/blob/master/repos/examples/real-world/node_modules/array-includes/LICENSE/README.md) [![Downloads](http://img.shields.io/npm/dm/array-includes.svg)](http://npm-stat.com/charts.html?package=array-includes)

[![npm badge](https://nodei.co/npm/array-includes.png?downloads=true\&stars=true)](https://npmjs.org/package/array-includes)

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](http://www.ecma-international.org/ecma-262/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.

## Getting started

```
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`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/array-includes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
