Array methods
Array.prototype.includes()
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
| Name | Type | Description |
|---|---|---|
| value | any | Value to find. |
| fromIndex | Number | Starting 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));