Learning outcomes of this tutorial
Map function explained
Map fucntion
Map function returns a new array based upon original array. Original array dosen't gets modified.
Map function can at most accept 3 parameters current Element, index, orignal Array of which index and orignal Array parameters are optional to add.
const orignalArray=[1,2,3,4,5]
const newArray = orignalArray.map((currentElement,currentIndex,orignalArray)=>
{return currentElement*2}
)
console.log("orignalArray: ",orignalArray)
console.log("new Array: ",newArray)
That's it for this blog.
Happy Learning !!
Happy Coding !!
Top comments (0)