_.add(augend, addend)

Adds two numbers.

Arguments

  1. augend (number): The first number to add.
  2. addend (number): The second number to add.

Returns

(number): Returns the sum.

Example

  1. _.add(6, 4);
  2. // => 10

_.ceil(n, [precision=0])

Calculates n rounded up to precision.

Arguments

  1. n (number): The number to round up.
  2. [precision=0] (number): The precision to round up to.

Returns

(number): Returns the rounded up number.

Example

  1. _.ceil(4.006);
  2. // => 5
  3. _.ceil(6.004, 2);
  4. // => 6.01
  5. _.ceil(6040, -2);
  6. // => 6100

_.floor(n, [precision=0])

Calculates n rounded down to precision.

Arguments

  1. n (number): The number to round down.
  2. [precision=0] (number): The precision to round down to.

Returns

(number): Returns the rounded down number.

Example

  1. _.floor(4.006);
  2. // => 4
  3. _.floor(0.046, 2);
  4. // => 0.04
  5. _.floor(4060, -2);
  6. // => 4000

_.max(collection, [iteratee], [thisArg])

Gets the maximum value of collection. If collection is empty or falsey -Infinity is returned. If an iteratee function is provided it’s invoked for each value in collection to generate the criterion by which the value is ranked. The iteratee is bound to thisArg and invoked with three arguments: (value, index, collection).

If a property name is provided for iteratee the created _.property style callback returns the property value of the given element.

If a value is also provided for thisArg the created _.matchesProperty style callback returns true for elements that have a matching property value, else false.

If an object is provided for iteratee the created _.matches style callback returns true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [iteratee] (Function|Object|string): The function invoked per iteration.
  3. [thisArg] (*): The this binding of iteratee.

Returns

(*): Returns the maximum value.

Example

  1. _.max([4, 2, 8, 6]);
  2. // => 8
  3. _.max([]);
  4. // => -Infinity
  5. var users = [
  6. { 'user': 'barney', 'age': 36 },
  7. { 'user': 'fred', 'age': 40 }
  8. ];
  9. _.max(users, function(chr) {
  10. return chr.age;
  11. });
  12. // => { 'user': 'fred', 'age': 40 }
  13. // using the `_.property` callback shorthand
  14. _.max(users, 'age');
  15. // => { 'user': 'fred', 'age': 40 }

_.min(collection, [iteratee], [thisArg])

Gets the minimum value of collection. If collection is empty or falsey Infinity is returned. If an iteratee function is provided it’s invoked for each value in collection to generate the criterion by which the value is ranked. The iteratee is bound to thisArg and invoked with three arguments: (value, index, collection).

If a property name is provided for iteratee the created _.property style callback returns the property value of the given element.

If a value is also provided for thisArg the created _.matchesProperty style callback returns true for elements that have a matching property value, else false.

If an object is provided for iteratee the created _.matches style callback returns true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [iteratee] (Function|Object|string): The function invoked per iteration.
  3. [thisArg] (*): The this binding of iteratee.

Returns

(*): Returns the minimum value.

Example

  1. _.min([4, 2, 8, 6]);
  2. // => 2
  3. _.min([]);
  4. // => Infinity
  5. var users = [
  6. { 'user': 'barney', 'age': 36 },
  7. { 'user': 'fred', 'age': 40 }
  8. ];
  9. _.min(users, function(chr) {
  10. return chr.age;
  11. });
  12. // => { 'user': 'barney', 'age': 36 }
  13. // using the `_.property` callback shorthand
  14. _.min(users, 'age');
  15. // => { 'user': 'barney', 'age': 36 }

_.round(n, [precision=0])

Calculates n rounded to precision.

Arguments

  1. n (number): The number to round.
  2. [precision=0] (number): The precision to round to.

Returns

(number): Returns the rounded number.

Example

  1. _.round(4.006);
  2. // => 4
  3. _.round(4.006, 2);
  4. // => 4.01
  5. _.round(4060, -2);
  6. // => 4100

_.sum(collection, [iteratee], [thisArg])

Gets the sum of the values in collection.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [iteratee] (Function|Object|string): The function invoked per iteration.
  3. [thisArg] (*): The this binding of iteratee.

Returns

(number): Returns the sum.

Example

  1. _.sum([4, 6]);
  2. // => 10
  3. _.sum({ 'a': 4, 'b': 6 });
  4. // => 10
  5. var objects = [
  6. { 'n': 4 },
  7. { 'n': 6 }
  8. ];
  9. _.sum(objects, function(object) {
  10. return object.n;
  11. });
  12. // => 10
  13. // using the `_.property` callback shorthand
  14. _.sum(objects, 'n');
  15. // => 10