_.add(augend, addend)

Adds two numbers.

Since

3.4.0

Arguments

  1. augend (number): The first number in an addition.
  2. addend (number): The second number in an addition.

Returns

(number): Returns the total.

Example

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

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

Computes number rounded up to precision.

Since

3.10.0

Arguments

  1. number (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

_.divide(dividend, divisor)

Divide two numbers.

Since

4.7.0

Arguments

  1. dividend (number): The first number in a division.
  2. divisor (number): The second number in a division.

Returns

(number): Returns the quotient.

Example

  1. _.divide(6, 4);
  2. // => 1.5

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

Computes number rounded down to precision.

Since

3.10.0

Arguments

  1. number (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(array)

Computes the maximum value of array. If array is empty or falsey, undefined is returned.

Since

0.1.0

Arguments

  1. array (Array): The array to iterate over.

Returns

(*): Returns the maximum value.

Example

  1. _.max([4, 2, 8, 6]);
  2. // => 8
  3. _.max([]);
  4. // => undefined

_.maxBy(array, [iteratee=_.identity])

This method is like _.max except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked. The iteratee is invoked with one argument: (value).

Since

4.0.0

Arguments

  1. array (Array): The array to iterate over.
  2. [iteratee=_.identity] (Function): The iteratee invoked per element.

Returns

(*): Returns the maximum value.

Example

  1. var objects = [{ 'n': 1 }, { 'n': 2 }];
  2. _.maxBy(objects, function(o) { return o.n; });
  3. // => { 'n': 2 }
  4. // The `_.property` iteratee shorthand.
  5. _.maxBy(objects, 'n');
  6. // => { 'n': 2 }

_.mean(array)

Computes the mean of the values in array.

Since

4.0.0

Arguments

  1. array (Array): The array to iterate over.

Returns

(number): Returns the mean.

Example

  1. _.mean([4, 2, 8, 6]);
  2. // => 5

_.meanBy(array, [iteratee=_.identity])

This method is like _.mean except that it accepts iteratee which is invoked for each element in array to generate the value to be averaged. The iteratee is invoked with one argument: (value).

Since

4.7.0

Arguments

  1. array (Array): The array to iterate over.
  2. [iteratee=_.identity] (Function): The iteratee invoked per element.

Returns

(number): Returns the mean.

Example

  1. var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  2. _.meanBy(objects, function(o) { return o.n; });
  3. // => 5
  4. // The `_.property` iteratee shorthand.
  5. _.meanBy(objects, 'n');
  6. // => 5

_.min(array)

Computes the minimum value of array. If array is empty or falsey, undefined is returned.

Since

0.1.0

Arguments

  1. array (Array): The array to iterate over.

Returns

(*): Returns the minimum value.

Example

  1. _.min([4, 2, 8, 6]);
  2. // => 2
  3. _.min([]);
  4. // => undefined

_.minBy(array, [iteratee=_.identity])

This method is like _.min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked. The iteratee is invoked with one argument: (value).

Since

4.0.0

Arguments

  1. array (Array): The array to iterate over.
  2. [iteratee=_.identity] (Function): The iteratee invoked per element.

Returns

(*): Returns the minimum value.

Example

  1. var objects = [{ 'n': 1 }, { 'n': 2 }];
  2. _.minBy(objects, function(o) { return o.n; });
  3. // => { 'n': 1 }
  4. // The `_.property` iteratee shorthand.
  5. _.minBy(objects, 'n');
  6. // => { 'n': 1 }

_.multiply(multiplier, multiplicand)

Multiply two numbers.

Since

4.7.0

Arguments

  1. multiplier (number): The first number in a multiplication.
  2. multiplicand (number): The second number in a multiplication.

Returns

(number): Returns the product.

Example

  1. _.multiply(6, 4);
  2. // => 24

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

Computes number rounded to precision.

Since

3.10.0

Arguments

  1. number (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

_.subtract(minuend, subtrahend)

Subtract two numbers.

Since

4.0.0

Arguments

  1. minuend (number): The first number in a subtraction.
  2. subtrahend (number): The second number in a subtraction.

Returns

(number): Returns the difference.

Example

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

_.sum(array)

Computes the sum of the values in array.

Since

3.4.0

Arguments

  1. array (Array): The array to iterate over.

Returns

(number): Returns the sum.

Example

  1. _.sum([4, 2, 8, 6]);
  2. // => 20

_.sumBy(array, [iteratee=_.identity])

This method is like _.sum except that it accepts iteratee which is invoked for each element in array to generate the value to be summed. The iteratee is invoked with one argument: (value).

Since

4.0.0

Arguments

  1. array (Array): The array to iterate over.
  2. [iteratee=_.identity] (Function): The iteratee invoked per element.

Returns

(number): Returns the sum.

Example

  1. var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  2. _.sumBy(objects, function(o) { return o.n; });
  3. // => 20
  4. // The `_.property` iteratee shorthand.
  5. _.sumBy(objects, 'n');
  6. // => 20