Function objGet

  • Retrieves the value associated with the specified key from an object.

    Type Parameters

    • V

    Parameters

    • obj: Record<ObjectKey, V>

      The object from which to retrieve the value.

    • key: ObjectKey

      The key of the value to retrieve.

    Returns V | undefined

    The value of the specified key in the object, or undefined if the key does not exist.

    Example

    const myObj = { name: 'John', age: 30 };
    objGet(myObj, 'name');
    //=> 'John'
    objGet(myObj, 'age');
    //=> 30
    objGet(myObj, 'address');
    //=> undefined

Generated using TypeDoc