Javascript
JavaScript Fundamentals -- Arrays in JavaScript

Array.includes

Mute
Current Time 0:00
/
Duration Time 0:00
Loaded: 0%
Progress: 0%
Stream TypeLIVE
Remaining Time -0:00
 
PRO

The includes method is used to determine if an array includes a given value. It doesn't work with passing objects to the method, but other types will work. The return is a boolean, true if found, false if it isn't. Here's an example:

const names = ['Preston', 'Amanda'];
console.log(names.includes('Amanda'); // true
console.log(names.includes('Brooke'); // false
 

I finished! On to the next chapter