Options
All
  • Public
  • Public/Protected
  • All
Menu

Module unset

Index

References

Functions Object

References

Renames and re-exports __type

Object Functions

  • unset<T>(object: T, path: string[]): T
  • unset<T>(object: T, path: string): T
  • Removes the property at path of object.

    Note: This method mutates object.

    since

    5.3.0

    see

    get,has,set

    example
    const object = { 'a': [{ 'b': { 'c': 7 } }] }
    unset(object, 'a[0].b.c')
    // => true

    console.log(object)
    // => { 'a': [{ 'b': {} }] }

    unset(object, ['a', '0', 'b', 'c'])
    // => true

    console.log(object)
    // => { 'a': [{ 'b': {} }] }

    Type parameters

    • T

    Parameters

    • object: T

      The object to modify.

    • path: string[]

      The path of the property to unset.

    Returns T

    Returns true if the property is deleted, else false.

  • Type parameters

    • T

    Parameters

    • object: T
    • path: string

    Returns T