JavaScript Array includes() methodThe JavaScript array includes() method checks whether the given array contains the specified element. It returns true if an array contains the element, otherwise false. SyntaxThe includes() method is represented by the following syntax: Parameterelement - The value to be searched. start - It is optional. It represents the index from where the method starts search. ReturnA Boolean value. JavaScript Array includes() method exampleHere, we will understand includes() method through various examples. Example 1Let's see a simple example to determine whether the given array contains the specified element. Test it NowOutput: true Example 2In this example, we will provide the index from where the search starts. Test it NowOutput: false Example 3Let's see one more example to determine whether the includes() method is case-sensitive. Test it NowOutput: false
Next TopicJavaScript Array
|