Copies properties from a given thing. Existing properties will be overwritten and new properties will be added. If this function is used on a typed thing, all properties of the source must be valid according the type specification, otherwise an exception will be raised and no properties will be copied.
It is not possible to use assign(..)
to set a property with a relation unless the source if of the same Type.
This function generates a change.
thing.assign(source)
Argument | Type | Description |
---|---|---|
source | thing (required) | Thing from which the properties are copied. |
Returns the thing
to which the properties are assigned.
This code shows an example using assign():
scores = {
iris: 10,
job: 20
};
scores.assign({
job: 80,
tijs: 90
});
Return value in JSON format
{
"iris": 10,
"job": 80,
"tijs": 90
}