Function defaultTo

  • 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.

    Type Parameters

    • T

    Parameters

    • value: any

      The value to check.

    • defaultValue: T

      The default value.

    Returns T

    Returns the resolved value.

    5.12.0

    defaultTo(1, 10)
    // => 1

    defaultTo(undefined, 10)
    // => 10