Function isDefined

  • Checks if a given value is defined or not.

    Example

    isDefined(null)
    // =>false

    isDefined(undefined)
    // => false

    isDefined(NaN)
    // =>false

    isDefined(true)
    // => true

    isDefined(false)
    // => true

    isDefined(0)
    // => true

    isDefined(111)
    // => true

    isDefined('')
    // => true

    isDefined('message')
    // => true

    isDefined([])
    // => true

    isDefined({})
    // => true

    isDefined({ message: 'hello' })
    // => true

    isDefined(function () {}))
    // => true

    Type Parameters

    • T

      The type of the input value.

    Parameters

    • value: undefined | null | T

      The value to be checked for definedness.

    Returns value is NonNullable<T>

    true if the given value is defined, and false otherwise.

Generated using TypeDoc v0.24.7