Array methods

Array.prototype.includes()

Try the free JavaScript compiler

Tests membership with SameValueZero. NaN matches itself; missing positions are read as undefined unless an inherited value exists. Negative fromIndex counts from the end.

Formal Syntax & Structure

javascript syntaxjavascript
array.includes(value, fromIndex)

Parameters & Attributes

NameTypeDescription
valueanyValue to find.
fromIndexNumberStarting index; default zero.

Return Value

boolean

Whether a match was found.

Working Example

Example Snippetjavascript
const a=[NaN];console.log(a.includes(NaN),a.includes(0));
JavaScript Reference