Home > shorts > Check whether an array includes a certain value
Check whether an array includes a certain value
The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
Option: fromIndex is the position in this array at which to begin searching for valueToFind
const languages = [
"JavaScript", "TypeScript", "Ruby", "Python"
]
languages.includes("Ruby") // true
languages.includes("Ruby", 2) // true
languages.includes("Ruby", 3) // false
languages.includes("Ruby", -1) // false
Check the demo here => CodePen