Function objDefineGet

  • Try to define a get object property accessor for the target object, if a function is past as the value this will be assumed to be a getter function and NOT the value.

    Type Parameters

    • T
    • V = any

    Parameters

    • target: T

      The object on which to define the property.

    • key: PropertyKey

      The name of the property to be defined or modified

    • value: V | (() => V)

      The value or a function that returns the value

    • Optional configurable: boolean

      Can the value be changed, defaults to true.

    • Optional enumerable: boolean

      Should this get property be enumerable, defaults to true.

    Returns T

    The object that was passed to the function

    Deprecated

    It is recommended that you use objDefine instead objDefineGet or objDefineAccessors as it provides a deterministic way for identifying whether the value is a value or a function rather than wrapping any function value in another function.