The JavaScript TypedArray includes() method to check if a particular element is present in the array or not. It is case-sensitive.
Syntax:
array.includes(searchElement, start)
Parameters:
searchElement: It represents the current element’s value.
start: It represents the index position to start the search.
Returns:
It returns true if the specified element is present in the array, otherwise returns false.
Example 1:
<!DOCTYPE html> <html> <body> <script type="text/javascript"> var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"]; result = Jewels.includes("GOLD") document.write(result); </script> </body> </html>
Example 2:
<!DOCTYPE html> <html> <body> <script type="text/javascript"> const testArray = new Uint8Array([45, 67, 34, 48, 12]); document.write(testArray.includes(34)); document.write("</br>"); document.write(testArray.includes(34, 3)); </script> </body> </html>