CodesJava

Easy learning with example program codes

JavaScript Array includes() method

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 which have to be searched. It is required.
start: It represents the index from where the search starts. It is optional.

Returns:
Returns true if 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>

Output:

true
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status