githubEdit

array-includes

Build Statusarrow-up-right dependency statusarrow-up-right dev dependency statusarrow-up-right Licensearrow-up-right Downloadsarrow-up-right

npm badgearrow-up-right

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

This package implements the es-shim APIarrow-up-right interface. It works in an ES3-supported environment and complies with the proposed specarrow-up-right.

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])

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

Tests

Simply clone the repo, npm install, and run npm test

Last updated