filter

Summary

Returns a new array with all elements of the original array that pass the specified condition.

Signatures

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

Usage

public T[] filter(bool(T currentValue) callback)

Returns

A new array with all elements of the original array that pass the specified condition.

Parameters

callback

A function which provides the test logic.

Description

Returns a new array with all elements of the original array that pass the specified condition.

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, 3, 4, 5, 6, 8, 10 ];
int[] oddNumbers = numbers.filter(bool(int currentValue) {
    return currentValue % 2 == 1;
});
Console.log(oddNumbers.toString());

Share

HTML | BBCode | Direct Link