Translate all items in an array to another array of items.
The translation function that is provided to this method is called for each item in the array and is passed one argument: The item to be translated.
The function can then return the translated value, 'null' (to remove the item), or an array of values - which will be flattened into the full array.
Arguments:
| array | Array | |
|---|---|---|
| The Array to translate. | ||
| callback | Function | |
The function to process each item against. The argument to the function is the list item. The function can return any value. Optionally, this argument may be a string rather than a function. If the argument is a string, it is treated as a short "lambda-form" function, with "a" representing the list item. For example, "a * a" may be passed instead of "function(a){ return a * a; }".
function callback(elementOfArray, indexInArray) {
var replacementValue;
this; // unmapped
return replacementValue;
}
| ||