Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
classapi-page

fluid.remove_if(source, fn)

Section
Column
width70%

Scan through a list of objects, removing those which match a predicate. Similar to jQuery.grep, only acts on the list in-place by removal, rather than by creating a new list by inclusion.

Code Block
javascript
javascript
bgColorwhite
borderStylenonejavascript
fluid.remove_if(source, fn);

File name: Fluid.js

Parameters

Span
classborderless-table

source

(Array or Object) The list of objects to be scanned over.

fn

(Type) A predicate function determining whether an element should be removed. This accepts the standard signature (object, index) and returns a "truthy" result to indicate that the supplied object should be removed from the list.

Return Value

Span
classborderless-table

(Array or Object)

The source, transformed by the operation of removing the matched elements. The supplied list is modified by this operation..

Column
width5%

Column

See Also


Example

Code Block
javascript
javascript
fluid.remove_if(listOfPermissions, function (permItem) {
    return !permManager.resolve(permItem);
});

In this example, each object in a list of permission objects is examined using a function called permManager.resolve(). If this function fails to resolve the item, it will be removed from the list.