map

Summary

Returns a new array with the specified operation applied to all elements of the original array.

Signatures

Click on a signature to select it and view its documentation.

Usage

public ResT[] map(ResT(T currentValue) callback)

Returns

A new array with the specified operation applied to all elements of the original array.

Parameters

callback

A function which provides the operation logic.

Description

Returns a new array with the specified operation applied to all elements of the original array.

This method was standardized in ECMAScript 5 for JavaScript. For web browsers that do not support ECMAScript 5, JS++ will provide a polyfill for this method only if it is used.

Examples

Basic Usage
1
2
3
4
5
6
7
import System;
 
int[] numbers = [ 2, 4, 6, 8, 10 ];
int[] subtract1 = numbers.map(int(int currentValue) {
    return currentValue - 1;
});
Console.log(subtract1.toString());

Share

HTML | BBCode | Direct Link