TypedArray some() JavaScript

The Javascript TypedArray some() method is used to examine the elements of an array according to a given condition.

Syntax:

array.some(function(value, index, arr), thisValue)

Parameters:
value: It represents the current element’s value.
index: It represents the index position of the current element.
arr: It represents the array on which some() method have to be called.
thisValue: It represents this argument for the function.

Returns:
It returns true if the specified elements of the array pass the given condition, otherwise returns false.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
function func(n, i, a)   
{  return n > 5;  }  
function num()   
{  
var a = [100,200,300,400,500];  
var value = a.some(func);  
document.write(value);  
}  num();  
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
function isNegative(element, index, array) {
  return element < 0;
}
 
const mixArray = new Int8Array([-12, 23, -34, 45, -56]);
const positiveArray = new Int8Array([12, 23, 34, 45, 56]);
 
document.write(mixArray.some(isNegative));
document.write("</br>");
 
document.write(positiveArray.some(isNegative));
 
</script>
</body>
</html>