Learn the important functions and concepts of array methods in JavaScript

Today we are going to see about important functions of arrays that every developer must know. First let us know about little bit of array. Array is nothing but a collection of elements and it contains many built-in properties and methods to resolve any task. Now let’s get deep into the topic.

  • some()
  • every()
  • flat()
  • filter()
  • forEach()
  • findIndex()
  • find ()
  • sort()
  • concat()
  • flatmap()

Some()

The some() method is used to test atleast one element in the array passes the test implemented by the callback function. It is possible to assign a value for this when executing the callback function by using argument.

Definition:

arr.some(callback(element[, index[, array]])[, thisArg])

Example:

const a = [1, 2, 3, 5, 8].some(item => item > 5)
const b = [1, 2, 3, 4, 5].some(item => item > 5)

console.log(a)
console.log(b)

---------
Output
---------
> true
> false

#javascript #developer

Importance of JavaScript Array Methods that Every Developer Must Know
2.20 GEEK