Javascript - .includes() and .indexOf()
📖 Read the lesson
Code Life
By Pierre Marsaa
Is It in There? includes
To know whether an array contains a value, use
includes()
. It answers with a boolean:
true
or
false
.
↗️
Loading editor...
↶
▶️ Run
↷
Since the result is a boolean, it fits directly in a condition:
↗️
Loading editor...
↶
▶️ Run
↷
Verify