Skip to main content

Command Palette

Search for a command to run...

#Javascript find method

Published
•1 min read•View as Markdown

''' In JavaScript find method is take argument as callback function and returns the first element which element we have to find Let's see some examples to understand easy. '''

\[let arr=[5,6,7,8,8]\] \\let num=arr.find(val=> val % 2==0) \\console.log(num) \\output:6; \\so it loop through array and it checks if it's divisible 0 it returns first match;

38 views