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
const array = [1,2,4];
console.log(array.includes(3)) // false as item 3 is not present
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)
filteredProduct = [
{productId: 12, name: "Monitor", price:100, sku:"12341"}
]
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)
['Monitor', 'Mouse', 'Keyboard', 'Headphone'] // Map with Name
#nodejs #javascript #web-development