Syntax array.map(function(currentValue, index, arr), thisValue) Parameter Values Parameter Description function(currentValue, index, arr) Required. A function to be run for each element in the array. Function arguments: Argument Description currentValue Required. The value of the current element index Optional. The array index of the current element arr Optional. The array object the current element belongs to thisValue Optional. A value to be passed to the function to be used as its "this" value. If this parameter is empty, the value "undefined" will be passed as its "this" value examples service.currencyList.map(each({value:each.currencySymbol,displayValue:each.currencySymbol})) ###################################################################### const persons = [ {firstname : "Malcom", lastname: "Reynolds"}, {firstname : "Kaylee", lastname: "Frye"}, {firstname : "Jayne", lastname: "Cobb"} ]; persons.map(getFullName); function getFullName(item) { return [item.firstname,item.lastname].join(" "); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter