Class Index | File Index

Classes


Function Namespace Pot.filter


Defined in: <potlite.js>.

Function Namespace Summary
Constructor Attributes Constructor Name and Description
 
Pot.filter(object, callback, (context))
Creates a new object with all elements that pass the test implemented by the provided function.
Function Namespace Detail
Pot.filter(object, callback, (context))
Creates a new object with all elements that pass the test implemented by the provided function. This method like Array.prototype.filter
  function isBigEnough(value, index, array) {
    return (value >= 10);
  }
  var filtered = Pot.filter([12, 5, 8, 130, 44], isBigEnough);
  debug(filtered);
  // @results [12, 130, 44]
  function isBigEnough(value, key, object) {
    return (value >= 10);
  }
  var object = {a: 1, b: 20, c: 7, d: 5, e: 27, f: 99};
  var result = Pot.filter(object, isBigEnough);
  debug(result);
  // @results {b: 20, e: 27, f: 99}
Parameters:
{Array|Object|*} object
A target object.
{Function} callback
A callback function.
{*} (context)
(Optional) Object to use as `this` when executing callback.
Returns:
{*} Return the result of each callbacks.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:35:45 GMT+0900 (JST)