
Array.prototype.map() – Creates a **new array** by transforming each element. Does not mutate the original array.
๐ Syntax
const newArray = array.map((element, index, array) => {
return /* transformed value */;
}, thisArg);
๐งช Example
const prices=[10,20];
const gst = prices.map(p=>p*1.18);
console.log(gst); // [11.8, 23.6]
Comments
Post a Comment