Wednesday, January 21, 2026
HomeLanguagesJavascriptTypeScript Array some() Method

TypeScript Array some() Method

The Array.some() is an inbuilt TypeScript function which is used to check for some element in the array passes the test implemented by the provided function.
Syntax:

array.some(callback[, thisObject])

Parameter: This method accept two parameter as mentioned above and described below:

  • callback : This parameter is the Function to test for each element.
  • thisObject : This parameter is the Object to use as this when executing callback.

Return Value: This method returns true if some element in this array satisfies the provided testing function. 
Below example illustrate the  Array  some() method in TypeScriptJS:
Example 1: 

TypeScript




// check for positive number 
function ispositive(element, index, array)
{ 
   return element > 0;
} 
 
// Driver code
var arr = [ 11, 89, 23, 7, 98 ]; 
  
// check for positive number 
var value = arr.some(ispositive); 
console.log( value );


Output: 

true

Example 2: 

TypeScript




// check for even number 
function iseven(element, index, array) 
{  
   return (element % 2 == 0);  
}   
// Driver code
var arr = [ 11, 89, 23, 7, 91 ]; 
  
// check for positive number 
var value = arr.some(iseven); 
console.log( value );


Output: 

 

false

 

RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7220 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS