Class: _

_

new _(value) → {Object}

Creates a `lodash` object which wraps the given value to enable intuitive 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`, `at`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `constant`, `countBy`, `create`, `createCallback`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `mapValues`, `matches`, `max`, `memoize`, `merge`, `min`, `noop`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `property`, `pull`, `push`, `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, `xor`, and `zip` The non-chainable wrapper functions are: `capitalize`, `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `now`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, `template`, `trim`, `trimLeft`, `trimRight`, `unescape`, `uniqueId`, and `value` The wrapper functions `first`, `last`, and `sample` return wrapped values when `n` is provided, otherwise they return unwrapped values. Explicit chaining can be enabled by using the `_.chain` method.
Parameters:
Name Type Description
value * The value to wrap in a `lodash` instance.
Source:
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> chain

Enables explicit method chaining on the wrapper object.
Source:
Example
var characters = [
  { 'name': 'barney', 'age': 36 },
  { 'name': 'fred',   'age': 40 }
];

// without explicit chaining
_(characters).first();
// => { 'name': 'barney', 'age': 36 }

// with explicit chaining
_(characters).chain()
  .first()
  .pick('age')
  .value();
// => { 'age': 36 }

<static> toString

Produces the `toString` result of the wrapped value.
Source:
Example
_([1, 2, 3]).toString();
// => '1,2,3'

<static> valueOf

Extracts the wrapped value.
Source:
Example
_([1, 2, 3]).valueOf();
// => [1, 2, 3]