Array some() Method
This method checks whether at least one of the elements of the array satisfies the condition checked by the argument function.
Example:
Here is an example of the basic use of the Array some() method.
Javascript
// JavaScript to illustrate // lastIndexOf() method function isGreaterThan5(element, index, array) { return element > 5; } function func() { // Original array let array = [2, 5, 8, 1, 4]; // Checking for condition in array let value = array.some(isGreaterThan5); console.log(value); } func(); |
true
Best-Known JavaScript Array Methods
An array is a special variable in all the languages that are used to store different elements. JavaScript array contains some built-in properties that every JavaScript developer should know how to use and when or where to use them. We can use them to add, remove, iterate, or manipulate data as per our requirements.