assignDeep
Sets multiple properties on a map instance or a property that wasn't predefined.
map.assignDeep(props)
Similar to .assign(), .assignDeep()
will overwrite
values within a map
with values from props
. Where .assign()
will replace values or
properties one level deep, .assignDeep()
will overwrite values or properties on objects
and lists recursively.
Properties not in props
will not be changed.
import {DefineMap, DefineList} from "can";
const MyMap = DefineMap.extend({
list: DefineList,
name: "string"
});
const obj = new MyMap({
list: ["1", "2", "3"],
foo: "bar"
});
obj.assignDeep({
list: ["first"]
});
console.log( obj.serialize() ); //-> { foo: "bar", list: ["first", "2", "3"] }
Parameters
- props
{Object}
:A collection of key-value pairs to set. If any properties already exist on the map, they will be overwritten.