Iterates through this array, calling the passed function for each element, passing to the function the element as the first parameter. The method can take an optional second parameter as an Array object (arguments). The elements of this array will be passed to the function as additional parameters. Returns a new array containing the values returned by the passed function. as Function, arguments? as Array) as Array


  • func. A reference to a function. This function must have been defined with at least one parameter as the current element will be passed to it. This function may have additional parameters defined and these will be passed to it as the contents of the optional arguments array. The return value for this function will be inserted into a new array that will be returned after iteration through all elements has occurred
  • arguments. Optional Array object. Each element of this array will be passed to func as additional parameters after the current element


  • A new Array object containing the values returned by the passed func function


function exclaim(e) {
    return e.uppercase + "!"

function prefix(e, what) {
    return what + e

var a = ["a", "b", "c", "d"]
var b = # ["A!", "B!", "C!", "D!"]
var c =, ["*"]) # ["*a", "*b", "*c", "*d"]

print(a) # => ["a", "b", "c", "d"]
print(b) # => ["A!", "B!", "C!", "D!"]
print(c) # => ["*a", "*b", "*c", "*d"]