arrayMap

Iterates over every entry of the array and calls the closure function to work on the element of the array. The returned value will be set at the same index in a new array and the new array will be returned

arrayMap(array, function(item [,index, array])) → returns Array

Member Function Syntax

someArray.map(function(item [,index, array]))

arrayMap Argument Reference

array
Required

The input array

function
Required

Closure or a function reference that will be called for each of the iteration. The arguments passed to the callback are

item: item in the array
index: index of the array
array: a reference of the original arrray

Links more information about arrayMap

Examples sample code invoking the arrayMap function


Script Syntax

complexData = [ {a: 4}, {a: 18}, {a: 51} ];
newArray = arrayMap( complexData, function(item){
   return item.a;
});
writeDump(newArray);

Expected Result: [4, 18, 51]


Fork me on GitHub