TinyMCE:API/tinymce/grep

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Method: grep

Summary

Filters out items from the input array by calling the specified function for each item. If the function returns false the item will be excluded if it returns true it will be included.

Syntax

<Array> grep(<Array> a, <function> f)

Parameters

a
Array of items to loop though.
f
Function to call for each item. Include/exclude depends on it's return value.

Returns

New array with values imported and filtered based in input.

Examples

// Filter out some items, this will return an array with 4 and 5
var items = tinymce.grep([1,2,3,4,5], function(v) {return v > 3;});
Personal tools