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 interface. It works in an ES3-supported environment and complies with the proposed spec.
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 = ;var assert = ;var arr = 'one' 'two' ; ; // true; // false; // false
Example
var arr = 1 'foo' NaN -0; assert;assert;assert;assert; assert;assert; assert;assert;assert;
/* when Array#includes is not present */delete Arrayprototypeincludes;var shimmedIncludes = includes; assert;assert;
/* when Array#includes is present */var shimmedIncludes = includes; assert;assert;
Tests
Simply clone the repo, npm install
, and run npm test