Object.assign()

Update elements of the given Object.

Signature

Object.assign(target: Any, update: Any): Any

Description

Update target with update. If target and updated have matching keys, the matching target key value is updated. If update doesn’t exist in target, the update key:value pair is added to target.

The assign() method doesn’t remove fields that have a value of null.

Parameters

Parameter Type Required Description

target

Any

Yes

Object to update.

update

Any

Yes

Key:value pair to update target with.

Return value

Type Description

Any

Updated target Object.

Examples

Object.assign({ 'a' : 0 }, { 'b' : 'x' })
{
  a: 0,
  b: "x"
}

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!