TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript TypedArray find() Method

JavaScript TypedArray find() Method with example, join() method, javascript typedarray methods, keys() method, indexOf() method, includes() method, forEach() method, entries(), every(), find(), filter(), copyWithin() method etc.

<< Back to JAVASCRIPT

JavaScript TypedArray find() Method

The JavaScript find() method is used to get the value of the first element in the array that satisfies the provided condition. The find() method apply the function once for each element present in the array. The function returns a true value, if it is found in the array and does not check the remaining value. Otherwise,it returns undefined.

  • find() does not execute the function for empty arrays.
  • find() does not change the original value.

Syntax:

array.find(function(value, index, arr))

Parameters:

Value (required): The value of the current element.

Index (optional): The array index of the current element.

Arr: The array object the current element belongs to.

Return value:

It returns the array element value if the elements in the array satisfy the condition, otherwise it returns undefined.

Browser Support:

Chrome 45.0
Edge 7.1
Firefox 25.0
Opera 32.0

Example 1

JavaScript Array find() Method

<script type="text/javascript">
// JavaScript to illustrate find() method
function JavaTpoint(value)
{
return value >12;
}
 // Input array
var arr = [1,2,3,4,5,6,7,8,9,12,11,14];
var result = arr.find(JavaTpoint);
document.write(result) 
// expected output: arr[Output:14]
</script> 
Test it Now

Output:

14

Example 2

JavaScript Array find() Method

<script type="text/javascript">
// JavaScript to illustrate find() method
function JavaTpoint(value)
{
return value ==15;
}
 // Input array
var arr = [1,2,3,4,5,6,7,8,9,12,11,14];
var result = arr.find(JavaTpoint);
document.write(result) 
// expected output: arr[Output: undefined] 
</script> 
Test it Now

Output:

Undefined





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf