defaultTo

Util
since 4.14.0

Arguments

  • * The value to check.
  • * The default value.

Returns

* the resolved value.

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.

Example of Lodash _.defaultTo

_.defaultTo(1, 10);
// => 1

_.defaultTo(undefined, 10);
// => 10