JavaScript TypedArray includes() Method - JavaScript Tutorial

JavaScript TypedArray includes() Method

BLUF: This tutorial on JavaScript TypedArray includes() Method provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript TypedArray includes() Method

Understanding JavaScript TypedArray includes() Method is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience