JavaScript TypedArray includes() Method

The includes method for arrays in JavaScript is a built-in function that checks the existence of a specified element within an array. It returns true if the element can be found in the array; otherwise, it yields false.

  • It is important to note that the includes method is case sensitive.
  • Syntax:

    Example
    
    array.includes(searchElement, start)
    

    Parameters:

Search : The element to search for

Begin: The default value is set to 0. This indicates the index at which the search operation will commence.

Return value:

It returns a Boolean value, either True or False.

Browser Support:

Chrome 41
Edge 9
Firefox 40
Opera 28

Example 1

JavaScript TypedArray includes Method

Example

<script type="text/javascript">

// JavaScript to illustrate includes() method

  // Taking input as an array 

    var pyVisualizer= [12,24,56,78,2];

     a = arr.includes(2)

  document.write(a);

// expected output: arr[Output:2]

</script>

Output:

Example 2

JavaScript TypedArray includes Method

Example

<script type="text/javascript">

// JavaScript to illustrate includes() method

  // Taking input as an array 

    var pyVisualizer= [12,24,56,78];

     a = arr.includes(2)

 

    document.write(a);

// expected output: arr[Output:false]

</script>

Output:

Input Required

This code uses input(). Please provide values below: