Home » JavaScript Array every() Method

JavaScript Array every() Method

by Online Tutorials Library

JavaScript Array every() method

The JavaScript array every() method checks whether all the given elements in an array are satisfying the provided condition. It returns true when each given array element satisfying the condition otherwise false.

Syntax

The every() method is represented by the following syntax:

Parameter

callback – It represents the function that test the condition.

currentvalue – The current element of array.

index – It is optional. The index of current element.

arr – It is optional. The array on which every() operated.

thisArg – It is optional. The value to use as this while executing callback.

Return

A Boolean value.

JavaScript Array every() method example

Let’s see some examples of every() method.

Example 1

Let’s check the marks of a student.

Test it Now

Output:

false  

Example 2

In this example, we will test whether the number of elements present in an array are satisfying the specified value.

Test it Now

Output:

true false  

Next TopicJavaScript Array

You may also like