On this page
  1. Array.includes
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Array.includes

Prev: flatMap | Up: Array | Next: some
Rel: Array, Array & Typed Arrays Guide
Ref: MDN Web Docs — Array.includes
Tags: #public #web #javascript #builtins #array #tier/core


Signature & Overview

arr.includes(value, fromIndex?)

Returns true if arr contains value using SameValueZero (handles NaN correctly).

Notes & Pitfalls

Example

const roles = ["admin", "editor"];
console.assert(roles.includes("admin") === true);
console.assert([NaN].includes(NaN) === true);

Linked from

Related notes