Function setEnumerable

  • Sets the enumerable property of the specified properties of an object to true.

    Parameters

    • object: Record<ObjectKey, any>

      The object whose properties' enumerable property will be set to true.

    • Rest ...properties: string[]

    Returns void

    void

    Example

    const obj = { a: 1, b: 2, c: 3 };
    setEnumerable(obj, 'a', 'b');
    Object.keys(obj);;
    //=> ['a', 'b']

    Remarks

    This function uses Object.defineProperty to set the enumerable property.

    Throws

    Will throw an error if any of the specified properties do not exist on the object.

    See

    Object.defineProperty

Generated using TypeDoc