What about something like this?
const arr = [1,2,3];
const el = 2;
console.log(arr.includes(el)) // true
More Related Contents:
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- Converting a JS object to an array using jQuery
- javascript filter array of objects
- Most efficient way to convert an HTMLCollection to an Array
- Passing an array as a function parameter in JavaScript
- How to get a number of random elements from an array?
- Merge JavaScript objects in array with same key
- Find object by id in an array of JavaScript objects
- Merge multiple objects inside the same array into one object [duplicate]
- javascript search array of arrays
- How do I zip two arrays in JavaScript?
- How do I sort an array of objects based on the ordering of another array?
- JavaScript – get array element fulfilling a condition
- Length of a JavaScript associative array
- JavaScript Array: get “range” of items
- Add a property to a JavaScript array
- Create a reset of javascript Array prototype when Array.prototype has been modified?
- Javascript recursive array flattening
- How to free up the memory in JavaScript
- Trying to capitalize the first character in array of strings, why this is not working?
- Removing undefined values from Array
- How to remove duplicates from a two-dimensional array? [closed]
- Javascript – sorting array by multiple criteria
- spread operator vs array.concat()
- How to get an Array with jQuery, multiple with the same name
- Sort a Javascript Array by frequency and then filter repeats
- How can I loop through enum values for display in radio buttons? [duplicate]
- Using jQuery inArray with array of JavaScript Objects
- Can forEach in JavaScript make a return? [duplicate]
- Why does the `map` method apparently not work on arrays created via `new Array(count)`?