I need your help in understanding below codes.
map<U>(mapFunction: (task: Task, index: number)=> U) {
return this.tasks.map(mapFunction);
}
forEach<U>(mapFunction: (task: Task, index: number)=> U) {
return this.tasks.forEach(mapFunction);
}
Can anyone explain me how these codes work. I'm trying to search it but failed. I know there is a term for using these codes. I just don't get the term
It's nothing but fat arrow in type script. this gets convert to java script using transpilers and Babel is one of the popular for this job
Here is at least some information if not all.
It's called a
javascript map function
In short: It itererates over array elements and calling functions on them
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.