This method is like defaultTo except that it accepts multiple default values and returns the first one that is not NaN, null, or undefined.
defaultTo
NaN
null
undefined
The value to check.
Rest
The default values.
Returns the resolved value.
5.0.0
_.defaultTo
defaultToAny(1, 10, 20)// => 1defaultToAny(undefined, 10, 20)// => 10defaultToAny(undefined, null, 20)// => 20defaultToAny(undefined, null, NaN)// => NaN Copy
defaultToAny(1, 10, 20)// => 1defaultToAny(undefined, 10, 20)// => 10defaultToAny(undefined, null, 20)// => 20defaultToAny(undefined, null, NaN)// => NaN
This method is like
defaultTo
except that it accepts multiple default values and returns the first one that is notNaN
,null
, orundefined
.