Options
All
  • Public
  • Public/Protected
  • All
Menu

Module defaultTo

Index

References

Functions

References

Renames and re-exports defaultTo

Functions

  • defaultTo<T>(a: T, b: null): T
  • defaultTo<T, U>(a: T, b: U): U
  • defaultTo<T>(a: T): { (b: null): T; <U>(b: U): U }
  • Returns the second argument if it is not null, undefined or NaN otherwise the first argument is returned.

    example
     var defaultTo42 = defaultTo(42);

    defaultTo42(null); //=> 42
    defaultTo42(undefined); //=> 42
    defaultTo42('Example'); //=> 'Example'
    defaultTo42(parseInt('string')); //=> 42

    Type parameters

    • T

    Parameters

    • a: T
    • b: null

    Returns T

    The the second value or the default value

  • Returns the second argument if it is not null, undefined or NaN otherwise the first argument is returned.

    example
     var defaultTo42 = defaultTo(42);

    defaultTo42(null); //=> 42
    defaultTo42(undefined); //=> 42
    defaultTo42('Example'); //=> 'Example'
    defaultTo42(parseInt('string')); //=> 42

    Type parameters

    • T

    • U

    Parameters

    • a: T
    • b: U

    Returns U

    The the second value or the default value

  • Returns the second argument if it is not null, undefined or NaN otherwise the first argument is returned.

    example
     var defaultTo42 = defaultTo(42);

    defaultTo42(null); //=> 42
    defaultTo42(undefined); //=> 42
    defaultTo42('Example'); //=> 'Example'
    defaultTo42(parseInt('string')); //=> 42

    Type parameters

    • T

    Parameters

    • a: T

    Returns { (b: null): T; <U>(b: U): U }

    The the second value or the default value

      • (b: null): T
      • <U>(b: U): U
      • Parameters

        • b: null

        Returns T

      • Type parameters

        • U

        Parameters

        • b: U

        Returns U

Generated using TypeDoc