The JavaScript array includes() method is used to check whether the given array contains the specified element.
Syntax:
array.includes (element,start)
Parameters:
element: It represents the value that has to be searched. It is required.
start: It represents the index from where the search starts. It is optional.
Returns:
Returns true if the given array contains the specified element else returns false.
Example:
<!DOCTYPE html> <html> <head> </head> <body> <script> var a = ["GOLD","SILVER","DIAMOND","RUBY","PLATINUM"] var result=a.includes("DIAMOND"); document.writeln(result); </script> </body> </html>