_.defaultTo

_.defaultTo(value, defaultValue)

Checks value to determine whether a default value should be returned in its place. The defaultValue is returned if value is NaN, null, or undefined.

Since

4.14.0

Arguments

  1. value (*): The value to check.
  2. defaultValue (*): The default value.

Returns

(*): Returns the resolved value.

Example

_.defaultTo(1, 10);
// => 1
 
_.defaultTo(undefined, 10);
// => 10
doc_Lodash
2016-11-27 16:36:14
Comments
Leave a Comment

Please login to continue.