Check if an array contains a value
Question:
How to check if an array contains a value? Answer:
const myArray = [1,2,3];
myArray.includes(1);
Description:
You can check if an array contains the given value in JavaScript by using the includes
method.
Reference:
JavaScript array includes() reference
Share "How to check if an array contains a value?"
Related snippets:
- Check if an array contains a value
- Append an array to another in JavaScript
- Get the first element of an array in JavaScript
- Convert Map values to array in JavaScript
- Convert array to comma separated string using JavaScript
- Get the minimum value in an array using JavaScript
- Get the maximum value in an array using JavaScript
- Remove duplicates from array in JavaScript
- Split a string into words
- Use foreach in JavaScript
Tags:
check, array, includes, contains, value, item, javascript Technical term:
Check if an array contains a value