JavaScript Array some()
JavaScript Array some()
The some() method is used to check if any array elements pass a test which is provided as a callback function. It executes the callback function once for each array element. It will return true and stops if the function returns true for one of the array elements. However, it will return false if the function returns false for all of the array elements. It does not execute the function for empty array elements and does not change the original array.
Syntax:-
Its syntax is:- array.some(function(value, index, arr), this)
Return:-
Its return is:- a boolean i.e, return true if any array element pass test else false.
Further Explanation:-
Parameter | Description | ||||||
function | Required. A function to run for each array element. | ||||||
Function parameters:
|
|||||||
this | Optional. A value is passed to the function to be used as this value. Default is undefined. |