JavaScript is a powerful language, because you can write an entire software without adopting any other programming language at all.

And without array manipulation do you think it’s possible to write a software?Here I have tried to list some frequently used array operation you may need to use.

Tried to talk less , Code more. Directly used code example without documentation like stuff

Array includes

const array = [1,2,4];
console.log(array.includes(3)) // false as item 3 is not present

Array Filter

const product = [

{productId: 12, name: "Monitor", price:100, sku:"12341"},
{productId: 14, name: "Mouse", price:10, sku:"12342"},
{productId: 15, name: "Keyboard", price:12, sku:"12343"},
{productId: 16, name: "Headphone", price:20, sku:"12345"}
]
const filteredProduct = product.filter((item)=>{
   return item.price>=100
})
console.log("Filtered Product",filteredProduct)

Output

filteredProduct = [
  {productId: 12, name: "Monitor", price:100, sku:"12341"}
]

Array map

const product = [

{productId: 12, name: "Monitor", price:100, sku:"12341"},
{productId: 14, name: "Mouse", price:10, sku:"12342"},
{productId: 15, name: "Keyboard", price:12, sku:"12343"},
{productId: 16, name: "Headphone", price:20, sku:"12345"}
]
const filteredProduct = product.map((item)=>{
 return item.name
})
console.log("Filtered Product",filteredProduct)

Output

['Monitor', 'Mouse', 'Keyboard', 'Headphone'] // Map with Name

#nodejs #javascript #web-development

8 High Frequency JavaScript Array Functions for Developers
19.30 GEEK