Class: _

_

new _

Creates a lodash object, which wraps the given value, to enable method chaining.

In addition to Lo-Dash methods, wrappers also have the following Array methods: concat, join, pop, push, reverse, shift, slice, sort, splice, and unshift

Chaining is supported in custom builds as long as the value method is implicitly or explicitly included in the build.

The chainable wrapper functions are: after, assign, bind, bindAll, bindKey, chain, compact, compose, concat, countBy, createCallback, debounce, defaults, defer, delay, difference, filter, flatten, forEach, forIn, forOwn, functions, groupBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, object, omit, once, pairs, partial, partialRight, pick, pluck, push, range, reject, rest, reverse, shuffle, slice, sort, sortBy, splice, tap, throttle, times, toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip

The non-chainable wrapper functions are: clone, cloneDeep, contains, escape, every, find, has, identity, indexOf, isArguments, isArray, isBoolean, isDate, isElement, isEmpty, isEqual, isFinite, isFunction, isNaN, isNull, isNumber, isObject, isPlainObject, isRegExp, isString, isUndefined, join, lastIndexOf, mixin, noConflict, parseInt, pop, random, reduce, reduceRight, result, shift, size, some, sortedIndex, runInContext, template, unescape, uniqueId, and value

The wrapper functions first and last return wrapped values when n is passed, otherwise they return unwrapped values.

Parameters:
Name Type Description
value Mixed

The value to wrap in a lodash instance.

Source:
  • lib/fwlib/lodash.js, line 531
Returns:

Returns a lodash instance.

Type
Object
Example
var wrapped = _([1, 2, 3]);

// returns an unwrapped value
wrapped.reduce(function(sum, num) {
  return sum + num;
});
// => 6

// returns a wrapped value
var squares = wrapped.map(function(num) {
  return num * num;
});

_.isArray(squares);
// => false

_.isArray(squares.value());
// => true

Members

<static> defaults :Function

Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to undefined. Once a property is set, additional defaults of the same property will be ignored.

Source:
  • lib/fwlib/lodash.js, line 1429
Example
var food = { 'name': 'apple' };
_.defaults(food, { 'name': 'banana', 'type': 'fruit' });
// => { 'name': 'apple', 'type': 'fruit' }

<static> extend :Function

Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback function is passed, it will be executed to produce the assigned values. The callback is bound to thisArg and invoked with two arguments; (objectValue, sourceValue).

Source:
  • lib/fwlib/lodash.js, line 1220
Example
_.assign({ 'name': 'moe' }, { 'age': 40 });
// => { 'name': 'moe', 'age': 40 }

var defaults = _.partialRight(_.assign, function(a, b) {
  return typeof a == 'undefined' ? b : a;
});

var food = { 'name': 'apple' };
defaults(food, { 'name': 'banana', 'type': 'fruit' });
// => { 'name': 'apple', 'type': 'fruit' }

<static> flatten

Flattens a nested array (the nesting can be to any depth). If isShallow is truthy, array will only be flattened a single level. If callback is passed, each element of array is passed through a callback before flattening. The callback is bound to thisArg and invoked with three arguments; (value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Source:
  • lib/fwlib/lodash.js, line 3725
Example
_.flatten([1, [2], [3, [[4]]]]);
// => [1, 2, 3, 4];

_.flatten([1, [2], [3, [[4]]]], true);
// => [1, 2, 3, [[4]]];

var stooges = [
  { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
  { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
];

// using "_.pluck" callback shorthand
_.flatten(stooges, 'quotes');
// => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']

<static> forIn :Function

Iterates over object's own and inherited enumerable properties, executing the callback for each property. The callback is bound to thisArg and invoked with three arguments; (value, key, object). Callbacks may exit iteration early by explicitly returning false.

Source:
  • lib/fwlib/lodash.js, line 1492
Example
function Dog(name) {
  this.name = name;
}

Dog.prototype.bark = function() {
  alert('Woof, woof!');
};

_.forIn(new Dog('Dagny'), function(value, key) {
  alert(key);
});
// => alerts 'name' and 'bark' (order is not guaranteed)

<static> forOwn :Function

Iterates over an object's own enumerable properties, executing the callback for each property. The callback is bound to thisArg and invoked with three arguments; (value, key, object). Callbacks may exit iteration early by explicitly returning false.

Source:
  • lib/fwlib/lodash.js, line 1517
Example
_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
  alert(key);
});
// => alerts '0', '1', and 'length' (order is not guaranteed)

<static> keys

Creates an array composed of the own enumerable property names of object.

Source:
  • lib/fwlib/lodash.js, line 1146
Example
_.keys({ 'one': 1, 'two': 2, 'three': 3 });
// => ['one', 'two', 'three'] (order is not guaranteed)

<static> parseInt

Converts the given value into an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used unless the value is a hexadecimal, in which case a radix of 16 is used.

Note: This method avoids differences in native ES3 and ES5 parseInt implementations. See http://es5.github.com/#E.

Source:
  • lib/fwlib/lodash.js, line 5142
Example
_.parseInt('08');
// => 8

<static> pluck :Function

Retrieves the value of a specified property from all elements in the collection.

Source:
  • lib/fwlib/lodash.js, line 3135
Example
var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

_.pluck(stooges, 'name');
// => ['moe', 'larry']

<static> support :Object

An object used to flag environments features.

Source:
  • lib/fwlib/lodash.js, line 619

<static> toString

Produces the toString result of the wrapped value.

Source:
  • lib/fwlib/lodash.js, line 5498
Example
_([1, 2, 3]).toString();
// => '1,2,3'

<static> unique

Creates a duplicate-value-free version of the array using strict equality for comparisons, i.e. ===. If the array is already sorted, passing true for isSorted will run a faster algorithm. If callback is passed, each element of array is passed through the callback before uniqueness is computed. The callback is bound to thisArg and invoked with three arguments; (value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Source:
  • lib/fwlib/lodash.js, line 4279
Example
_.uniq([1, 2, 1, 3, 1]);
// => [1, 2, 3]

_.uniq([1, 1, 2, 2, 3], true);
// => [1, 2, 3]

_.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); });
// => ['A', 'b', 'C']

_.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math);
// => [1, 2.5, 3]

// using "_.pluck" callback shorthand
_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]

<static> valueOf

Extracts the wrapped value.

Source:
  • lib/fwlib/lodash.js, line 5514
Example
_([1, 2, 3]).valueOf();
// => [1, 2, 3]

<static> where :Function

Examines each element in a collection, returning an array of all elements that have the given properties. When checking properties, this method performs a deep comparison between values to determine if they are equivalent to each other.

Source:
  • lib/fwlib/lodash.js, line 3495
Example
var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

_.where(stooges, { 'age': 40 });
// => [{ 'name': 'moe', 'age': 40 }]

Methods

<static> after

If n is greater than 0, a function is created that is restricted to executing func, with the this binding and arguments of the created function, only after it is called n times. If n is less than 1, func is executed immediately, without a this binding or additional arguments, and its result is returned.

Parameters:
Name Type Description
n Number

The number of times the function must be called before it is executed.

func Function

The function to restrict.

Source:
  • lib/fwlib/lodash.js, line 4443
Returns:

Returns the new restricted function.

Type
Function
Example
var renderNotes = _.after(notes.length, render);
_.forEach(notes, function(note) {
  note.asyncSave({ 'success': renderNotes });
});
// `renderNotes` is run once, after all notes have saved

<static> all

Checks if the callback returns a truthy value for all elements of a collection. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2649
Returns:

Returns true if all elements pass the callback check, else false.

Type
Boolean
Example
_.every([true, 1, null, 'yes'], Boolean);
// => false

var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

// using "_.pluck" callback shorthand
_.every(stooges, 'age');
// => true

// using "_.where" callback shorthand
_.every(stooges, { 'age': 50 });
// => false

<static> any

Checks if the callback returns a truthy value for any element of a collection. The function returns as soon as it finds passing value, and does not iterate over the entire collection. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3371
Returns:

Returns true if any element passes the callback check, else false.

Type
Boolean
Example
_.some([null, 0, 'yes', false], Boolean);
// => true

var food = [
  { 'name': 'apple',  'organic': false, 'type': 'fruit' },
  { 'name': 'carrot', 'organic': true,  'type': 'vegetable' }
];

// using "_.pluck" callback shorthand
_.some(food, 'organic');
// => true

// using "_.where" callback shorthand
_.some(food, { 'type': 'meat' });
// => false

<static> at

Creates an array of elements from the specified indexes, or keys, of the collection. Indexes may be specified as individual arguments or as arrays of indexes.

Parameters:
Name Type Argument Description
collection Array | Object | String

The collection to iterate over.

index1, index2, ... Array | Number | String <optional>

The indexes of collection to retrieve, either as individual arguments or arrays.

Source:
  • lib/fwlib/lodash.js, line 2500
Returns:

Returns a new array of elements corresponding to the provided indexes.

Type
Array
Example
_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
// => ['a', 'c', 'e']

_.at(['moe', 'larry', 'curly'], 0, 2);
// => ['moe', 'curly']

<static> bind

Creates a function that, when called, invokes func with the this binding of thisArg and prepends any additional bind arguments to those passed to the bound function.

Parameters:
Name Type Argument Description
func Function

The function to bind.

thisArg Mixed <optional>

The this binding of func.

arg1, arg2, ... Mixed <optional>

Arguments to be partially applied.

Source:
  • lib/fwlib/lodash.js, line 4476
Returns:

Returns the new bound function.

Type
Function
Example
var func = function(greeting) {
  return greeting + ' ' + this.name;
};

func = _.bind(func, { 'name': 'moe' }, 'hi');
func();
// => 'hi moe'

<static> bindAll

Binds methods on object to object, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of object will be bound.

Parameters:
Name Type Argument Description
object Object

The object to bind and assign the bound methods to.

methodName1, methodName2, ... String <optional>

Method names on the object to bind.

Source:
  • lib/fwlib/lodash.js, line 4502
Returns:

Returns object.

Type
Object
Example
var view = {
 'label': 'docs',
 'onClick': function() { alert('clicked ' + this.label); }
};

_.bindAll(view);
jQuery('#docs').on('click', view.onClick);
// => alerts 'clicked docs', when the button is clicked

<static> bindKey

Creates a function that, when called, invokes the method at object[key] and prepends any additional bindKey arguments to those passed to the bound function. This method differs from _.bind by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern.

Parameters:
Name Type Argument Description
object Object

The object the method belongs to.

key String

The key of the method.

arg1, arg2, ... Mixed <optional>

Arguments to be partially applied.

Source:
  • lib/fwlib/lodash.js, line 4548
Returns:

Returns the new bound function.

Type
Function
Example
var object = {
  'name': 'moe',
  'greet': function(greeting) {
    return greeting + ' ' + this.name;
  }
};

var func = _.bindKey(object, 'greet', 'hi');
func();
// => 'hi moe'

object.greet = function(greeting) {
  return greeting + ', ' + this.name + '!';
};

func();
// => 'hi, moe!'

<static> clone

Creates a clone of value. If deep is true, nested objects will also be cloned, otherwise they will be assigned by reference. If a callback function is passed, it will be executed to produce the cloned values. If callback returns undefined, cloning will be handled by the method instead. The callback is bound to thisArg and invoked with one argument; (value).

Parameters:
Name Type Argument Default Description
value Mixed

The value to clone.

deep Boolean <optional>
false

A flag to indicate a deep clone.

callback Function <optional>

The function to customize cloning values.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 1275
Returns:

Returns the cloned value.

Type
Mixed
Example
var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

var shallow = _.clone(stooges);
shallow[0] === stooges[0];
// => true

var deep = _.clone(stooges, true);
deep[0] === stooges[0];
// => false

_.mixin({
  'clone': _.partialRight(_.clone, function(value) {
    return _.isElement(value) ? value.cloneNode(false) : undefined;
  })
});

var clone = _.clone(document.body);
clone.childNodes.length;
// => 0

<static> cloneDeep

Creates a deep clone of value. If a callback function is passed, it will be executed to produce the cloned values. If callback returns undefined, cloning will be handled by the method instead. The callback is bound to thisArg and invoked with one argument; (value).

Note: This method is loosely based on the structured clone algorithm. Functions and DOM nodes are not cloned. The enumerable properties of arguments objects and objects created by constructors other than Object are cloned to plain Object objects. See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm.

Parameters:
Name Type Argument Description
value Mixed

The value to deep clone.

callback Function <optional>

The function to customize cloning values.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 1405
Returns:

Returns the deep cloned value.

Type
Mixed
Example
var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

var deep = _.cloneDeep(stooges);
deep[0] === stooges[0];
// => false

var view = {
  'label': 'docs',
  'node': element
};

var clone = _.cloneDeep(view, function(value) {
  return _.isElement(value) ? value.cloneNode(true) : undefined;
});

clone.node == view.node;
// => false

<static> collect

Creates an array of values by running each element in the collection through the callback. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2959
Returns:

Returns a new array of the results of each callback execution.

Type
Array
Example
_.map([1, 2, 3], function(num) { return num * 3; });
// => [3, 6, 9]

_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
// => [3, 6, 9] (order is not guaranteed)

var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

// using "_.pluck" callback shorthand
_.map(stooges, 'name');
// => ['moe', 'larry']

<static> compact

Creates an array with all falsey values of array removed. The values false, null, 0, "", undefined and NaN are all falsey.

Parameters:
Name Type Description
array Array

The array to compact.

Source:
  • lib/fwlib/lodash.js, line 3513
Returns:

Returns a new filtered array.

Type
Array
Example
_.compact([0, 1, false, 2, '', 3]);
// => [1, 2, 3]

<static> compose

Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions f(), g(), and h() produces f(g(h())). Each function is executed with the this binding of the composed function.

Parameters:
Name Type Argument Description
func1, func2, ... Function <optional>

Functions to compose.

Source:
  • lib/fwlib/lodash.js, line 4571
Returns:

Returns the new composed function.

Type
Function
Example
var greet = function(name) { return 'hi ' + name; };
var exclaim = function(statement) { return statement + '!'; };
var welcome = _.compose(exclaim, greet);
welcome('moe');
// => 'hi moe!'

<static> countBy

Creates an object composed of keys returned from running each element of the collection through the given callback. The corresponding value of each key is the number of times the key was returned by the callback. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2597
Returns:

Returns the composed aggregate object.

Type
Object
Example
_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
// => { '4': 1, '6': 2 }

_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
// => { '4': 1, '6': 2 }

_.countBy(['one', 'two', 'three'], 'length');
// => { '3': 2, '5': 1 }

<static> createCallback

Produces a callback bound to an optional thisArg. If func is a property name, the created callback will return the property value for a given element. If func is an object, the created callback will return true for elements that contain the equivalent object properties, otherwise it will return false.

Note: All Lo-Dash methods, that accept a callback argument, use _.createCallback.

Parameters:
Name Type Argument Default Description
func Mixed <optional>
identity

The value to convert to a callback.

thisArg Mixed <optional>

The this binding of the created callback.

argCount Number <optional>
3

The number of arguments the callback accepts.

Source:
  • lib/fwlib/lodash.js, line 4630
Returns:

Returns a callback function.

Type
Function
Example
var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

// wrap to create custom callback shorthands
_.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
  var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
  return !match ? func(callback, thisArg) : function(object) {
    return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
  };
});

_.filter(stooges, 'age__gt45');
// => [{ 'name': 'larry', 'age': 50 }]

// create mixins with support for "_.pluck" and "_.where" callback shorthands
_.mixin({
  'toLookup': function(collection, callback, thisArg) {
    callback = _.createCallback(callback, thisArg);
    return _.reduce(collection, function(result, value, index, collection) {
      return (result[callback(value, index, collection)] = value, result);
    }, {});
  }
});

_.toLookup(stooges, 'name');
// => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } }

<static> debounce

Creates a function that will delay the execution of func until after wait milliseconds have elapsed since the last time it was invoked. Pass an options object to indicate that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to the debounced function will return the result of the last func call.

Note: If leading and trailing options are true, func will be called on the trailing edge of the timeout only if the the debounced function is invoked more than once during the wait timeout.

Parameters:
Name Type Description
func Function

The function to debounce.

wait Number

The number of milliseconds to delay.

options Object

The options object. [leading=false] A boolean to specify execution on the leading edge of the timeout. [maxWait] The maximum time func is allowed to be delayed before it's called. [trailing=true] A boolean to specify execution on the trailing edge of the timeout.

Source:
  • lib/fwlib/lodash.js, line 4707
Returns:

Returns the new debounced function.

Type
Function
Example
var lazyLayout = _.debounce(calculateLayout, 300);
jQuery(window).on('resize', lazyLayout);

jQuery('#postbox').on('click', _.debounce(sendMail, 200, {
  'leading': true,
  'trailing': false
});

<static> defer

Defers executing the func function until the current call stack has cleared. Additional arguments will be passed to func when it is invoked.

Parameters:
Name Type Argument Description
func Function

The function to defer.

arg1, arg2, ... Mixed <optional>

Arguments to invoke the function with.

Source:
  • lib/fwlib/lodash.js, line 4804
Returns:

Returns the timer id.

Type
Number
Example
_.defer(function() { alert('deferred'); });
// returns from the function before `alert` is called

<static> delay

Executes the func function after wait milliseconds. Additional arguments will be passed to func when it is invoked.

Parameters:
Name Type Argument Description
func Function

The function to delay.

wait Number

The number of milliseconds to delay execution.

arg1, arg2, ... Mixed <optional>

Arguments to invoke the function with.

Source:
  • lib/fwlib/lodash.js, line 4826
Returns:

Returns the timer id.

Type
Number
Example
var log = _.bind(console.log, console);
_.delay(log, 1000, 'logged later');
// => 'logged later' (Appears after one second.)

<static> detect, findWhere

Examines each element in a collection, returning the first that the callback returns truthy for. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2777
Returns:

Returns the found element, else undefined.

Type
Mixed
Example
_.find([1, 2, 3, 4], function(num) {
  return num % 2 == 0;
});
// => 2

var food = [
  { 'name': 'apple',  'organic': false, 'type': 'fruit' },
  { 'name': 'banana', 'organic': true,  'type': 'fruit' },
  { 'name': 'beet',   'organic': false, 'type': 'vegetable' }
];

// using "_.where" callback shorthand
_.find(food, { 'type': 'vegetable' });
// => { 'name': 'beet', 'organic': false, 'type': 'vegetable' }

// using "_.pluck" callback shorthand
_.find(food, 'organic');
// => { 'name': 'banana', 'organic': true, 'type': 'fruit' }

<static> difference

Creates an array of array elements not present in the other arrays using strict equality for comparisons, i.e. ===.

Parameters:
Name Type Argument Description
array Array

The array to process.

array1, array2, ... Array <optional>

Arrays to check.

Source:
  • lib/fwlib/lodash.js, line 3543
Returns:

Returns a new array of array elements not present in the other arrays.

Type
Array
Example
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
// => [1, 3, 4]

<static> drop, tail

The opposite of _.initial, this method gets all but the first value of array. If a number n is passed, the first n values are excluded from the result. If a callback function is passed, elements at the beginning of the array are excluded from the result as long as the callback returns truthy. The callback is bound to thisArg and invoked with three arguments; (value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
array Array

The array to query.

callback|n Function | Object | Number | String <optional>
1

The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 4133
Returns:

Returns a slice of array.

Type
Array
Example
_.rest([1, 2, 3]);
// => [2, 3]

_.rest([1, 2, 3], 2);
// => [3]

_.rest([1, 2, 3], function(num) {
  return num < 3;
});
// => [3]

var food = [
  { 'name': 'banana', 'organic': true },
  { 'name': 'beet',   'organic': false },
];

// using "_.pluck" callback shorthand
_.rest(food, 'organic');
// => [{ 'name': 'beet', 'organic': false }]

var food = [
  { 'name': 'apple',  'type': 'fruit' },
  { 'name': 'banana', 'type': 'fruit' },
  { 'name': 'beet',   'type': 'vegetable' }
];

// using "_.where" callback shorthand
_.rest(food, { 'type': 'fruit' });
// => [{ 'name': 'beet', 'type': 'vegetable' }]

<static> each

Iterates over a collection, executing the callback for each element in the collection. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection). Callbacks may exit iteration early by explicitly returning false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function <optional>
identity

The function called per iteration.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2824
Returns:

Returns collection.

Type
Array | Object | String
Example
_([1, 2, 3]).forEach(alert).join(',');
// => alerts each number and returns '1,2,3'

_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
// => alerts each number value (order is not guaranteed)

<static> escape

Converts the characters &, <, >, ", and ' in string to their corresponding HTML entities.

Parameters:
Name Type Description
string String

The string to escape.

Source:
  • lib/fwlib/lodash.js, line 5045
Returns:

Returns the escaped string.

Type
String
Example
_.escape('Moe, Larry & Curly');
// => 'Moe, Larry & Curly'

<static> findIndex

This method is similar to _.find, except that it returns the index of the element that passes the callback check, instead of the element itself.

Parameters:
Name Type Argument Default Description
array Array

The array to search.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3593
Returns:

Returns the index of the found element, else -1.

Type
Mixed
Example
_.findIndex(['apple', 'banana', 'beet'], function(food) {
  return /^b/.test(food);
});
// => 1

<static> findKey

This method is similar to _.find, except that it returns the key of the element that passes the callback check, instead of the element itself.

Parameters:
Name Type Argument Default Description
object Object

The object to search.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 1451
Returns:

Returns the key of the found element, else undefined.

Type
Mixed
Example
_.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) {
  return num % 2 == 0;
});
// => 'b'

<static> foldl, inject

Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If accumulator is not passed, the first element of the collection will be used as the initial accumulator value. The callback is bound to thisArg and invoked with four arguments; (accumulator, value, index|key, collection).

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function <optional>
identity

The function called per iteration.

accumulator Mixed <optional>

Initial value of the accumulator.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3167
Returns:

Returns the accumulated value.

Type
Mixed
Example
var sum = _.reduce([1, 2, 3], function(sum, num) {
  return sum + num;
});
// => 6

var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
  result[key] = num * 3;
  return result;
}, {});
// => { 'a': 3, 'b': 6, 'c': 9 }

<static> foldr

This method is similar to _.reduce, except that it iterates over a collection from right to left.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function <optional>
identity

The function called per iteration.

accumulator Mixed <optional>

Initial value of the accumulator.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3210
Returns:

Returns the accumulated value.

Type
Mixed
Example
var list = [[0, 1], [2, 3], [4, 5]];
var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
// => [4, 5, 2, 3, 0, 1]

<static> groupBy

Creates an object composed of keys returned from running each element of the collection through the callback. The corresponding value of each key is an array of elements passed to callback that returned the key. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2874
Returns:

Returns the composed aggregate object.

Type
Object
Example
_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
// => { '4': [4.2], '6': [6.1, 6.4] }

_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
// => { '4': [4.2], '6': [6.1, 6.4] }

// using "_.pluck" callback shorthand
_.groupBy(['one', 'two', 'three'], 'length');
// => { '3': ['one', 'two'], '5': ['three'] }

<static> has

Checks if the specified object property exists and is a direct property, instead of an inherited property.

Parameters:
Name Type Description
object Object

The object to check.

property String

The property to check for.

Source:
  • lib/fwlib/lodash.js, line 1559
Returns:

Returns true if key is a direct property, else false.

Type
Boolean
Example
_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
// => true

<static> head, take

Gets the first element of the array. If a number n is passed, the first n elements of the array are returned. If a callback function is passed, elements at the beginning of the array are returned as long as the callback returns truthy. The callback is bound to thisArg and invoked with three arguments; (value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Description
array Array

The array to query.

callback|n Function | Object | Number | String <optional>

The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3663
Returns:

Returns the first element(s) of array.

Type
Mixed
Example
_.first([1, 2, 3]);
// => 1

_.first([1, 2, 3], 2);
// => [1, 2]

_.first([1, 2, 3], function(num) {
  return num < 3;
});
// => [1, 2]

var food = [
  { 'name': 'banana', 'organic': true },
  { 'name': 'beet',   'organic': false },
];

// using "_.pluck" callback shorthand
_.first(food, 'organic');
// => [{ 'name': 'banana', 'organic': true }]

var food = [
  { 'name': 'apple',  'type': 'fruit' },
  { 'name': 'banana', 'type': 'fruit' },
  { 'name': 'beet',   'type': 'vegetable' }
];

// using "_.where" callback shorthand
_.first(food, { 'type': 'fruit' });
// => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]

<static> identity

This method returns the first argument passed to it.

Parameters:
Name Type Description
value Mixed

Any value.

Source:
  • lib/fwlib/lodash.js, line 5063
Returns:

Returns value.

Type
Mixed
Example
var moe = { 'name': 'moe' };
moe === _.identity(moe);
// => true

<static> include

Checks if a given target element is present in a collection using strict equality for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

target Mixed

The value to check for.

fromIndex Number <optional>
0

The index to search from.

Source:
  • lib/fwlib/lodash.js, line 2542
Returns:

Returns true if the target element is found, else false.

Type
Boolean
Example
_.contains([1, 2, 3], 1);
// => true

_.contains([1, 2, 3], 1, 2);
// => false

_.contains({ 'name': 'moe', 'age': 40 }, 'moe');
// => true

_.contains('curly', 'ur');
// => true

<static> indexOf

Gets the index at which the first occurrence of value is found using strict equality for comparisons, i.e. ===. If the array is already sorted, passing true for fromIndex will run a faster binary search.

Parameters:
Name Type Argument Default Description
array Array

The array to search.

value Mixed

The value to search for.

fromIndex Boolean | Number <optional>
0

The index to search from or true to perform a binary search on a sorted array.

Source:
  • lib/fwlib/lodash.js, line 3769
Returns:

Returns the index of the matched value or -1.

Type
Number
Example
_.indexOf([1, 2, 3, 1, 2, 3], 2);
// => 1

_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
// => 4

_.indexOf([1, 1, 2, 2, 3, 3], 2, true);
// => 2

<static> initial

Gets all but the last element of array. If a number n is passed, the last n elements are excluded from the result. If a callback function is passed, elements at the end of the array are excluded from the result as long as the callback returns truthy. The callback is bound to thisArg and invoked with three arguments; (value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
array Array

The array to query.

callback|n Function | Object | Number | String <optional>
1

The function called per element or the number of elements to exclude. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3836
Returns:

Returns a slice of array.

Type
Array
Example
_.initial([1, 2, 3]);
// => [1, 2]

_.initial([1, 2, 3], 2);
// => [1]

_.initial([1, 2, 3], function(num) {
  return num > 1;
});
// => [1]

var food = [
  { 'name': 'beet',   'organic': false },
  { 'name': 'carrot', 'organic': true }
];

// using "_.pluck" callback shorthand
_.initial(food, 'organic');
// => [{ 'name': 'beet',   'organic': false }]

var food = [
  { 'name': 'banana', 'type': 'fruit' },
  { 'name': 'beet',   'type': 'vegetable' },
  { 'name': 'carrot', 'type': 'vegetable' }
];

// using "_.where" callback shorthand
_.initial(food, { 'type': 'vegetable' });
// => [{ 'name': 'banana', 'type': 'fruit' }]

<static> intersection

Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. ===.

Parameters:
Name Type Argument Description
array1, array2, ... Array <optional>

Arrays to process.

Source:
  • lib/fwlib/lodash.js, line 3870
Returns:

Returns a new array of unique elements that are present in all of the arrays.

Type
Array
Example
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
// => [1, 2]

<static> invert

Creates an object composed of the inverted keys and values of the given object.

Parameters:
Name Type Description
object Object

The object to invert.

Source:
  • lib/fwlib/lodash.js, line 1576
Returns:

Returns the created inverted object.

Type
Object
Example
 _.invert({ 'first': 'moe', 'second': 'larry' });
// => { 'moe': 'first', 'larry': 'second' }

<static> invoke

Invokes the method named by methodName on each element in the collection, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If methodName is a function, it will be invoked for, and this bound to, each element in the collection.

Parameters:
Name Type Argument Description
collection Array | Object | String

The collection to iterate over.

methodName Function | String

The name of the method to invoke or the function invoked per iteration.

arg1, arg2, ... Mixed <optional>

Arguments to invoke the method with.

Source:
  • lib/fwlib/lodash.js, line 2907
Returns:

Returns a new array of the results of each invoked method.

Type
Array
Example
_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
// => [[1, 5, 7], [1, 2, 3]]

_.invoke([123, 456], String.prototype.split, '');
// => [['1', '2', '3'], ['4', '5', '6']]

<static> isArguments

Checks if value is an arguments object.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1109
Returns:

Returns true, if the value is an arguments object, else false.

Type
Boolean
Example
(function() { return _.isArguments(arguments); })(1, 2, 3);
// => true

_.isArguments([1, 2, 3]);
// => false

<static> isArray

Checks if value is an array.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1129
Returns:

Returns true, if the value is an array, else false.

Type
Boolean
Example
(function() { return _.isArray(arguments); })();
// => false

_.isArray([1, 2, 3]);
// => true

<static> isBoolean

Checks if value is a boolean value.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1602
Returns:

Returns true, if the value is a boolean value, else false.

Type
Boolean
Example
_.isBoolean(null);
// => false

<static> isDate

Checks if value is a date.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1619
Returns:

Returns true, if the value is a date, else false.

Type
Boolean
Example
_.isDate(new Date);
// => true

<static> isElement

Checks if value is a DOM element.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1636
Returns:

Returns true, if the value is a DOM element, else false.

Type
Boolean
Example
_.isElement(document.body);
// => true

<static> isEmpty

Checks if value is empty. Arrays, strings, or arguments objects with a length of 0 and objects with no own enumerable properties are considered "empty".

Parameters:
Name Type Description
value Array | Object | String

The value to inspect.

Source:
  • lib/fwlib/lodash.js, line 1661
Returns:

Returns true, if the value is empty, else false.

Type
Boolean
Example
_.isEmpty([1, 2, 3]);
// => false

_.isEmpty({});
// => true

_.isEmpty('');
// => true

<static> isEqual

Performs a deep comparison between two values to determine if they are equivalent to each other. If callback is passed, it will be executed to compare values. If callback returns undefined, comparisons will be handled by the method instead. The callback is bound to thisArg and invoked with two arguments; (a, b).

Parameters:
Name Type Argument Description
a Mixed

The value to compare.

b Mixed

The other value to compare.

callback Function <optional>

The function to customize comparing values.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 1720
Returns:

Returns true, if the values are equivalent, else false.

Type
Boolean
Example
var moe = { 'name': 'moe', 'age': 40 };
var copy = { 'name': 'moe', 'age': 40 };

moe == copy;
// => false

_.isEqual(moe, copy);
// => true

var words = ['hello', 'goodbye'];
var otherWords = ['hi', 'goodbye'];

_.isEqual(words, otherWords, function(a, b) {
  var reGreet = /^(?:hello|hi)$/i,
      aGreet = _.isString(a) && reGreet.test(a),
      bGreet = _.isString(b) && reGreet.test(b);

  return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
});
// => true

<static> isFinite

Checks if value is, or can be coerced to, a finite number.

Note: This is not the same as native isFinite, which will return true for booleans and empty strings. See http://es5.github.com/#x15.1.2.5.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1906
Returns:

Returns true, if the value is finite, else false.

Type
Boolean
Example
_.isFinite(-101);
// => true

_.isFinite('10');
// => true

_.isFinite(true);
// => false

_.isFinite('');
// => false

_.isFinite(Infinity);
// => false

<static> isFunction

Checks if value is a function.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1923
Returns:

Returns true, if the value is a function, else false.

Type
Boolean
Example
_.isFunction(_);
// => true

<static> isNaN

Checks if value is NaN.

Note: This is not the same as native isNaN, which will return true for undefined and other values. See http://es5.github.com/#x15.1.2.4.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1986
Returns:

Returns true, if the value is NaN, else false.

Type
Boolean
Example
_.isNaN(NaN);
// => true

_.isNaN(new Number(NaN));
// => true

isNaN(undefined);
// => true

_.isNaN(undefined);
// => false

<static> isNull

Checks if value is null.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2008
Returns:

Returns true, if the value is null, else false.

Type
Boolean
Example
_.isNull(null);
// => true

_.isNull(undefined);
// => false

<static> isNumber

Checks if value is a number.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2025
Returns:

Returns true, if the value is a number, else false.

Type
Boolean
Example
_.isNumber(8.4 * 5);
// => true

<static> isObject

Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 1953
Returns:

Returns true, if the value is an object, else false.

Type
Boolean
Example
_.isObject({});
// => true

_.isObject([1, 2, 3]);
// => true

_.isObject(1);
// => false

<static> isPlainObject

Checks if a given value is an object created by the Object constructor.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2053
Returns:

Returns true, if value is a plain object, else false.

Type
Boolean
Example
function Stooge(name, age) {
  this.name = name;
  this.age = age;
}

_.isPlainObject(new Stooge('moe', 40));
// => false

_.isPlainObject([1, 2, 3]);
// => false

_.isPlainObject({ 'name': 'moe', 'age': 40 });
// => true

<static> isRegExp

Checks if value is a regular expression.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2096
Returns:

Returns true, if the value is a regular expression, else false.

Type
Boolean
Example
_.isRegExp(/moe/);
// => true

<static> isString

Checks if value is a string.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2113
Returns:

Returns true, if the value is a string, else false.

Type
Boolean
Example
_.isString('moe');
// => true

<static> isUndefined

Checks if value is undefined.

Parameters:
Name Type Description
value Mixed

The value to check.

Source:
  • lib/fwlib/lodash.js, line 2130
Returns:

Returns true, if the value is undefined, else false.

Type
Boolean
Example
_.isUndefined(void 0);
// => true

<static> last

Gets the last element of the array. If a number n is passed, the last n elements of the array are returned. If a callback function is passed, elements at the end of the array are returned as long as the callback returns truthy. The callback is bound to thisArg and invoked with three arguments;(value, index, array).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Description
array Array

The array to query.

callback|n Function | Object | Number | String <optional>

The function called per element or the number of elements to return. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3972
Returns:

Returns the last element(s) of array.

Type
Mixed
Example
_.last([1, 2, 3]);
// => 3

_.last([1, 2, 3], 2);
// => [2, 3]

_.last([1, 2, 3], function(num) {
  return num > 1;
});
// => [2, 3]

var food = [
  { 'name': 'beet',   'organic': false },
  { 'name': 'carrot', 'organic': true }
];

// using "_.pluck" callback shorthand
_.last(food, 'organic');
// => [{ 'name': 'carrot', 'organic': true }]

var food = [
  { 'name': 'banana', 'type': 'fruit' },
  { 'name': 'beet',   'type': 'vegetable' },
  { 'name': 'carrot', 'type': 'vegetable' }
];

// using "_.where" callback shorthand
_.last(food, { 'type': 'vegetable' });
// => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }]

<static> lastIndexOf

Gets the index at which the last occurrence of value is found using strict equality for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection.

Parameters:
Name Type Argument Default Description
array Array

The array to search.

value Mixed

The value to search for.

fromIndex Number <optional>
array.length-1

The index to search from.

Source:
  • lib/fwlib/lodash.js, line 4013
Returns:

Returns the index of the matched value or -1.

Type
Number
Example
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
// => 4

_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
// => 1

<static> max

Retrieves the maximum value of an array. If callback is passed, it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked with three arguments; (value, index, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3016
Returns:

Returns the maximum value.

Type
Mixed
Example
_.max([4, 2, 8, 6]);
// => 8

var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

_.max(stooges, function(stooge) { return stooge.age; });
// => { 'name': 'larry', 'age': 50 };

// using "_.pluck" callback shorthand
_.max(stooges, 'age');
// => { 'name': 'larry', 'age': 50 };

<static> memoize

Creates a function that memoizes the result of func. If resolver is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The func is executed with the this binding of the memoized function. The result cache is exposed as the cache property on the memoized function.

Parameters:
Name Type Argument Description
func Function

The function to have its output memoized.

resolver Function <optional>

A function used to resolve the cache key.

Source:
  • lib/fwlib/lodash.js, line 4851
Returns:

Returns the new memoizing function.

Type
Function
Example
var fibonacci = _.memoize(function(n) {
  return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
});

<static> merge

Recursively merges own enumerable properties of the source object(s), that don't resolve to undefined, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback function is passed, it will be executed to produce the merged values of the destination and source properties. If callback returns undefined, merging will be handled by the method instead. The callback is bound to thisArg and invoked with two arguments; (objectValue, sourceValue).

Parameters:
Name Type Argument Description
object Object

The destination object.

source1, source2, ... Object <optional>

The source objects.

callback Function <optional>

The function to customize merging properties.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2189
Returns:

Returns the destination object.

Type
Object
Example
var names = {
  'stooges': [
    { 'name': 'moe' },
    { 'name': 'larry' }
  ]
};

var ages = {
  'stooges': [
    { 'age': 40 },
    { 'age': 50 }
  ]
};

_.merge(names, ages);
// => { 'stooges': [{ 'name': 'moe', 'age': 40 }, { 'name': 'larry', 'age': 50 }] }

var food = {
  'fruits': ['apple'],
  'vegetables': ['beet']
};

var otherFood = {
  'fruits': ['banana'],
  'vegetables': ['carrot']
};

_.merge(food, otherFood, function(a, b) {
  return _.isArray(a) ? a.concat(b) : undefined;
});
// => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }

<static> methods

Creates a sorted array of all enumerable properties, own and inherited, of object that have function values.

Parameters:
Name Type Description
object Object

The object to inspect.

Source:
  • lib/fwlib/lodash.js, line 1534
Returns:

Returns a new array of property names that have function values.

Type
Array
Example
_.functions(_);
// => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]

<static> min

Retrieves the minimum value of an array. If callback is passed, it will be executed for each value in the array to generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked with three arguments; (value, index, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3085
Returns:

Returns the minimum value.

Type
Mixed
Example
_.min([4, 2, 8, 6]);
// => 2

var stooges = [
  { 'name': 'moe', 'age': 40 },
  { 'name': 'larry', 'age': 50 }
];

_.min(stooges, function(stooge) { return stooge.age; });
// => { 'name': 'moe', 'age': 40 };

// using "_.pluck" callback shorthand
_.min(stooges, 'age');
// => { 'name': 'moe', 'age': 40 };

<static> mixin

Adds functions properties of object to the lodash function and chainable wrapper.

Parameters:
Name Type Description
object Object

The object of function properties to add to lodash.

Source:
  • lib/fwlib/lodash.js, line 5089
Example
_.mixin({
  'capitalize': function(string) {
    return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
  }
});

_.capitalize('moe');
// => 'Moe'

_('moe').capitalize();
// => 'Moe'

<static> noConflict

Reverts the '_' variable to its previous value and returns a reference to the lodash function.

Source:
  • lib/fwlib/lodash.js, line 5118
Returns:

Returns the lodash function.

Type
Function
Example
var lodash = _.noConflict();

<static> object

Creates an object composed from arrays of keys and values. Pass either a single two dimensional array, i.e. [[key1, value1], [key2, value2]], or two arrays, one of keys and one of corresponding values.

Parameters:
Name Type Argument Default Description
keys Array

The array of keys.

values Array <optional>
[]

The array of values.

Source:
  • lib/fwlib/lodash.js, line 4403
Returns:

Returns an object composed of the given keys and corresponding values.

Type
Object
Example
_.zipObject(['moe', 'larry'], [30, 40]);
// => { 'moe': 30, 'larry': 40 }

<static> omit

Creates a shallow clone of object excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a callback function is passed, it will be executed for each property in the object, omitting the properties callback returns truthy for. The callback is bound to thisArg and invoked with three arguments; (value, key, object).

Parameters:
Name Type Argument Description
object Object

The source object.

callback|[prop1, Function | String

prop2, ...] The properties to omit or the function called per iteration.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2304
Returns:

Returns an object without the omitted properties.

Type
Object
Example
_.omit({ 'name': 'moe', 'age': 40 }, 'age');
// => { 'name': 'moe' }

_.omit({ 'name': 'moe', 'age': 40 }, function(value) {
  return typeof value == 'number';
});
// => { 'name': 'moe' }

<static> once

Creates a function that is restricted to execute func once. Repeat calls to the function will return the value of the first call. The func is executed with the this binding of the created function.

Parameters:
Name Type Description
func Function

The function to restrict.

Source:
  • lib/fwlib/lodash.js, line 4881
Returns:

Returns the new restricted function.

Type
Function
Example
var initialize = _.once(createApplication);
initialize();
initialize();
// `initialize` executes `createApplication` once

<static> pairs

Creates a two dimensional array of the given object's key-value pairs, i.e. [[key1, value1], [key2, value2]].

Parameters:
Name Type Description
object Object

The object to inspect.

Source:
  • lib/fwlib/lodash.js, line 2339
Returns:

Returns new array of key-value pairs.

Type
Array
Example
_.pairs({ 'moe': 30, 'larry': 40 });
// => [['moe', 30], ['larry', 40]] (order is not guaranteed)

<static> partial

Creates a function that, when called, invokes func with any additional partial arguments prepended to those passed to the new function. This method is similar to _.bind, except it does not alter the this binding.

Parameters:
Name Type Argument Description
func Function

The function to partially apply arguments to.

arg1, arg2, ... Mixed <optional>

Arguments to be partially applied.

Source:
  • lib/fwlib/lodash.js, line 4916
Returns:

Returns the new partially applied function.

Type
Function
Example
var greet = function(greeting, name) { return greeting + ' ' + name; };
var hi = _.partial(greet, 'hi');
hi('moe');
// => 'hi moe'

<static> partialRight

This method is similar to _.partial, except that partial arguments are appended to those passed to the new function.

Parameters:
Name Type Argument Description
func Function

The function to partially apply arguments to.

arg1, arg2, ... Mixed <optional>

Arguments to be partially applied.

Source:
  • lib/fwlib/lodash.js, line 4947
Returns:

Returns the new partially applied function.

Type
Function
Example
var defaultsDeep = _.partialRight(_.merge, _.defaults);

var options = {
  'variable': 'data',
  'imports': { 'jq': $ }
};

defaultsDeep(options, _.templateSettings);

options.variable
// => 'data'

options.imports
// => { '_': _, 'jq': $ }

<static> pick

Creates a shallow clone of object composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If callback is passed, it will be executed for each property in the object, picking the properties callback returns truthy for. The callback is bound to thisArg and invoked with three arguments; (value, key, object).

Parameters:
Name Type Argument Description
object Object

The source object.

callback|[prop1, Array | Function | String

prop2, ...] The function called per iteration or properties to pick, either as individual arguments or arrays.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2377
Returns:

Returns an object composed of the picked properties.

Type
Object
Example
_.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name');
// => { 'name': 'moe' }

_.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) {
  return key.charAt(0) != '_';
});
// => { 'name': 'moe' }

<static> random

Produces a random number between min and max (inclusive). If only one argument is passed, a number between 0 and the given number will be returned.

Parameters:
Name Type Argument Default Description
min Number <optional>
0

The minimum possible value.

max Number <optional>
1

The maximum possible value.

Source:
  • lib/fwlib/lodash.js, line 5165
Returns:

Returns a random number.

Type
Number
Example
_.random(0, 5);
// => a number between 0 and 5

_.random(5);
// => also a number between 0 and 5

<static> range

Creates an array of numbers (positive and/or negative) progressing from start up to but not including end.

Parameters:
Name Type Argument Default Description
start Number <optional>
0

The start of the range.

end Number

The end of the range.

step Number <optional>
1

The value to increment or decrement by.

Source:
  • lib/fwlib/lodash.js, line 4054
Returns:

Returns a new range array.

Type
Array
Example
_.range(10);
// => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

_.range(1, 11);
// => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

_.range(0, 30, 5);
// => [0, 5, 10, 15, 20, 25]

_.range(0, -10, -1);
// => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]

_.range(0);
// => []

<static> reject

The opposite of _.filter, this method returns the elements of a collection that callback does not return truthy for.

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3270
Returns:

Returns a new array of elements that did not pass the callback check.

Type
Array
Example
var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
// => [1, 3, 5]

var food = [
  { 'name': 'apple',  'organic': false, 'type': 'fruit' },
  { 'name': 'carrot', 'organic': true,  'type': 'vegetable' }
];

// using "_.pluck" callback shorthand
_.reject(food, 'organic');
// => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]

// using "_.where" callback shorthand
_.reject(food, { 'type': 'fruit' });
// => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]

<static> result

Resolves the value of property on object. If property is a function, it will be invoked with the this binding of object and its result returned, else the property value is returned. If object is falsey, then undefined is returned.

Parameters:
Name Type Description
object Object

The object to inspect.

property String

The property to get the value of.

Source:
  • lib/fwlib/lodash.js, line 5209
Returns:

Returns the resolved value.

Type
Mixed
Example
var object = {
  'cheese': 'crumpets',
  'stuff': function() {
    return 'nonsense';
  }
};

_.result(object, 'cheese');
// => 'crumpets'

_.result(object, 'stuff');
// => 'nonsense'

<static> runInContext

Create a new lodash function using the given context object.

Parameters:
Name Type Argument Default Description
context Object <optional>
window

The context object.

Source:
  • lib/fwlib/lodash.js, line 443
Returns:

Returns the lodash function.

Type
Function

<static> select

Examines each element in a collection, returning an array of all elements the callback returns truthy for. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 2710
Returns:

Returns a new array of elements that passed the callback check.

Type
Array
Example
var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
// => [2, 4, 6]

var food = [
  { 'name': 'apple',  'organic': false, 'type': 'fruit' },
  { 'name': 'carrot', 'organic': true,  'type': 'vegetable' }
];

// using "_.pluck" callback shorthand
_.filter(food, 'organic');
// => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]

// using "_.where" callback shorthand
_.filter(food, { 'type': 'fruit' });
// => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]

<static> shuffle

Creates an array of shuffled array values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.

Parameters:
Name Type Description
collection Array | Object | String

The collection to shuffle.

Source:
  • lib/fwlib/lodash.js, line 3291
Returns:

Returns a new shuffled collection.

Type
Array
Example
_.shuffle([1, 2, 3, 4, 5, 6]);
// => [4, 1, 6, 3, 5, 2]

<static> size

Gets the size of the collection by returning collection.length for arrays and array-like objects or the number of own enumerable properties for objects.

Parameters:
Name Type Description
collection Array | Object | String

The collection to inspect.

Source:
  • lib/fwlib/lodash.js, line 3324
Returns:

Returns collection.length or number of own enumerable properties.

Type
Number
Example
_.size([1, 2]);
// => 2

_.size({ 'one': 1, 'two': 2, 'three': 3 });
// => 3

_.size('curly');
// => 5

<static> sortBy

Creates an array of elements, sorted in ascending order by the results of running each element in the collection through the callback. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
collection Array | Object | String

The collection to iterate over.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 3427
Returns:

Returns a new array of sorted elements.

Type
Array
Example
_.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
// => [3, 1, 2]

_.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
// => [3, 1, 2]

// using "_.pluck" callback shorthand
_.sortBy(['banana', 'strawberry', 'apple'], 'length');
// => ['apple', 'banana', 'strawberry']

<static> sortedIndex

Uses a binary search to determine the smallest index at which the value should be inserted into array in order to maintain the sort order of the sorted array. If callback is passed, it will be executed for value and each element in array to compute their sort ranking. The callback is bound to thisArg and invoked with one argument; (value).

If a property name is passed for callback, the created "_.pluck" style callback will return the property value of the given element.

If an object is passed for callback, the created "_.where" style callback will return true for elements that have the properties of the given object, else false.

Parameters:
Name Type Argument Default Description
array Array

The array to inspect.

value Mixed

The value to evaluate.

callback Function | Object | String <optional>
identity

The function called per iteration. If a property name or object is passed, it will be used to create a ".pluck" or ".where" style callback, respectively.

thisArg Mixed <optional>

The this binding of callback.

Source:
  • lib/fwlib/lodash.js, line 4197
Returns:

Returns the index at which the value should be inserted into array.

Type
Number
Example
_.sortedIndex([20, 30, 50], 40);
// => 2

// using "_.pluck" callback shorthand
_.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
// => 2

var dict = {
  'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
};

_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
  return dict.wordToNumber[word];
});
// => 2

_.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
  return this.wordToNumber[word];
}, dict);
// => 2

<static> tap

Invokes interceptor with the value as the first argument, and then returns value. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.

Parameters:
Name Type Description
value Mixed

The value to pass to interceptor.

interceptor Function

The function to invoke.

Source:
  • lib/fwlib/lodash.js, line 5493
Returns:

Returns value.

Type
Mixed
Example
_([1, 2, 3, 4])
 .filter(function(num) { return num % 2 == 0; })
 .tap(alert)
 .map(function(num) { return num * num; })
 .value();
// => // [2, 4] (alerted)
// => [4, 16]

<static> template

A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.

Note: In the development build, _.template utilizes sourceURLs for easier debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl

For more information on precompiling templates see: http://lodash.com/#custom-builds

For more information on Chrome extension sandboxes see: http://developer.chrome.com/stable/extensions/sandboxingEval.html

Parameters:
Name Type Description
text String

The template text.

data Object

The data object used to populate the text.

options Object

The options object. escape - The "escape" delimiter regexp. evaluate - The "evaluate" delimiter regexp. interpolate - The "interpolate" delimiter regexp. sourceURL - The sourceURL of the template's compiled source. variable - The data object variable name.

Source:
  • lib/fwlib/lodash.js, line 5293
Returns:

Returns a compiled function when no data object is given, else it returns the interpolated text.

Type
Function | String
Example
// using a compiled template
var compiled = _.template('hello <%= name %>');
compiled({ 'name': 'moe' });
// => 'hello moe'

var list = '<% _.forEach(people, function(name) { %>
  • <%= name %>
  • <% }); %>'; _.template(list, { 'people': ['moe', 'larry'] }); // => '
  • moe
  • larry
  • ' // using the "escape" delimiter to escape HTML in data property values _.template('<%- value %>', { 'value': '