I was going through this blog to understand foreach loop, but the blog says that use of Array.map() is more efficient than for foreach. So, I tried implementing that in my Lightning Component, but it doesn't let me save and throws FIELD_INTEGRITY_EXCEPTION - ESLINT_ERROR --> Parsing error: Unexpected token => : Source
I'm trying to implement like below:
Use of forEach
arr.forEach((num, index) => {
return arr[index] = num * 2;
});
Use of Array.map():
let arr = [1, 2, 3, 4, 5];
let arr2 = arr.map(num => num * 2);
consle.log('>> '+arr2);
Here is what I'm originally trying to implement:
let cleanedMID = mcWrapper.map(mId.newMID => this.cleanMerchantID(component, event, mId.newMID));
console.log('>>'+cleanedMID);
Is this(Array.map()) possible in lightning framework to implement.
let cleanedMID = mcWrapper.map(mId.newMID => this.cleanMerchantID(component, event, mId.newMID)); console.log('>>'+cleanedMID);