indexOf() / includes()
Does the element exist / where is it?
Syntax
arr.indexOf(e) · arr.includes(e)
Description
indexOf returns the position (or -1 if not found), includes returns true/false.
Example
Loading editor…
Expected output
1 false
When to use?
Checking if a value exists in the list.