Login Register Help
API Documentation
Choose a stylesheet:

Functiondojo.filter (returns Array)

dojo.require("dojo._base.array");

This function corresponds to the JavaScript 1.6 Array.filter() method. For more details, see: http://developer.mozilla.org/en/docs/CoreJavaScript1.5Reference:GlobalObjects:Array:filter

parametertypedescription
arrArraythe array to iterate over.
callbackFunction|Stringa function that is invoked with three arguments (item, index, array). The return of this function is expected to be a boolean which determines whether the passed-in item will be included in the returned array.
thisObjectObjectOptional. may be used to scope the call to callback

Usage

var foo: Array=dojo.filter(arr: Array, callback: Function|String, thisObject: Object?);

Examples

Example 1

// returns [2, 3, 4]
dojo.filter([1, 2, 3, 4], function(item){ return item>1; });