How to check if a value is in an array in JavaScript?

To check if a value is in an array in JavaScript, use the Array.isArray function.

Here's how you do it:

const array = [];
const object = {};

// true
console.log(Array.isArray(array));

// false
console.log(Array.isArray(object));