includes()

noun

say it: “in-KLOODZ” /ɪnˈkluːdz/

A JavaScript method that answers true or false: does this array contain this value, or does this text contain this piece of text?

What does includes() do in JavaScript?

includes() — A method that reports whether an array contains a value or a string contains text.

const tags = ["javascript", "web"];
const hasJavaScript = tags.includes("javascript");

In a sentence

  • “Before adding a song, I check playlist.includes(song) so the same song isn't added twice.”

Level: Apprentice · More JavaScript terms at this level

Updated