Object.update
Object.update
Function
Merge one or more objects into the current object in place.
Syntax
object.update(source1, source2, ...)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| sourceN | Object | No | None | The source object to merge; non-object arguments are ignored. |
Return value
| Type | Description |
|---|---|
| Object | Returns the original object to facilitate continued chain calls. |
Return object fields
update() returns the same object reference that it was called on. The returned object first retains the original fields, and then writes the fields of each source object in parameter order; fields with the same name are overwritten by the source object written later.
Example
config = {host: '127.0.0.1'} config.update({port: 8080}) // Output: {"host":"127.0.0.1","port":8080} echo(config)
Notes
- update will modify the original object.
- update will refuse to write values that would create circular references.