Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/move-property/docs/types/index.d"

Index

Functions

Functions

Export assignment moveProperty

  • moveProperty(source: any, prop: string, target: any): boolean
  • Moves a property from one object to another object.

    Notes

    • The property is deleted from the source object and the property's descriptor is preserved during transfer.
    • If a source property is not configurable, the function throws an error, as the property cannot be deleted from the source object.

    Parameters

    • source: any

      source object

    • prop: string

      property to move

    • target: any

      target object

    Returns boolean

    boolean indicating whether operation was successful

    Example

    var obj1 = { 'a': 'b' };
    var obj2 = {};
    
    var bool = moveProperty( obj1, 'a', obj2 );
    // returns true

    Example

    var obj1 = { 'a': 'b' };
    var obj2 = {};
    
    var bool = moveProperty( obj1, 'c', obj2 );
    // returns false