Lowdefy
v3.17.2/Operators/_object/

_object

The _object operator can be used to run javascript Object methods.

Operator methods:

_object.assign

(objs: obj[]): object

The _object.assign method copies the values of one ore more source objects to a target objects. The first object in the arguments array is the target object, and the rest are source objects. Keys in the target object are overwritten. The result of _object.assign can be seen as a "shallow-merge" of all the objects in the array, with the values in later objects taken preferentially.

Arguments

array

An array of objects.

Examples

Merge three objects:
_object.assign:
  - firstName: Rachel
    lastName: Green
    series: Friends
  - firstName: Monica
    lastName: Geller
    address:
      street: 90 Bedford St
      city: New York
      zipCode: '10014'
      country: US
  - friends:
      - Ross Geller
      - Rachel Green
      - Chandler Bing
      - Phoebe Buffay
      - Joey Tribbiani

Returns:

firstName: Monica
lastName: Geller
series: Friends
address:
  street: 90 Bedford St
  city: New York
  zipCode: '10014'
  country: US
friends:
  - Ross Geller
  - Rachel Green
  - Chandler Bing
  - Phoebe Buffay
  - Joey Tribbiani

_object.defineProperty

(arguments: {
  on: object,
  key: string,
  descriptor: {
    value: any,
    configurable?: boolean,
    enumerable?: boolean,
    writable?: boolean
  }
}): any
(arguments: [
  on: object,
  key: string,
  descriptor: {
    value: any,
    configurable?: boolean,
    enumerable?: boolean,
    writable?: boolean
  }
]): any

The _object.defineProperty method defines a new property directly on an object, or modifies an existing property on an object, and returns the object. The first object in the arguments array, or the on parameter, is the target object to which the property will be applied. The second argument, or the key parameter, is the property name or key which will be applied to the target object. The third and last object argument, or the descriptor parameter, has serval options to consider, however, for the most common application set the value object key to the value that should be applied to the target object key. See Object.defineProperty for a more detailed description.

The _object.defineProperty method is handy when the key to set is variable.

Examples

Set a value to a object key:
_object.defineProperty:
  - firstName: Rachel
    series: Friends
  - lastName
  - descriptor:
      value: Green

Returns:

firstName: Rachel
lastName: Green
series: Friends

_object.keys

(obj: object): string[]

The _object.keys method returns an array with the objects keys.

Arguments

object

The object to get keys from.

Examples

Get the keys of an object:
_object.keys:
  firstName: Monica
  lastName: Geller
  address:
    street: 90 Bedford St
    city: New York
    zipCode: '10014'
    country: US
  friends:
    - Ross Geller
    - Rachel Green
    - Chandler Bing
    - Phoebe Buffay
    - Joey Tribbiani

Returns:

- firstName
- lastName
- address
- friends

_object.values

(obj: object): any[]

The _object.keys method returns an array with the values of all the fields in an object.

Arguments

object

The object to get keys from.

Examples

Get the values of an object:
_object.values:
  firstName: Monica
  lastName: Geller
  address:
    street: 90 Bedford St
    city: New York
    zipCode: '10014'
    country: US
  friends:
    - Ross Geller
    - Rachel Green
    - Chandler Bing
    - Phoebe Buffay
    - Joey Tribbiani

Returns:

- Monica
- Geller
- street: 90 Bedford St
  city: New York
  zipCode: '10014'
  country: US
- - Ross Geller
  - Rachel Green
  - Chandler Bing
  - Phoebe Buffay
  - Joey Tribbiani