update
Updates a list with new values or new property values.
list.update(newItems)
If newItems
is list like the values in newItems
will replace all values in list
. For example:
import {DefineList} from "can";
const list = new DefineList(["A","B"]);
list.update( ["a"] );
console.log( list.serialize() ); //-> ["a"]
If newItems
is an object, newItem
's properties and values will be used to overwrite
list
's properties and values. Any enumerable properties on list
that are
not in newItems
will be removed.
import {DefineList} from "can";
const list = new DefineList(["A","B"]);
list.update( {count: 1000, skip: 2} );
list.update( {count: 99} )
console.log( list.skip ); //-> undefined
NOTE: Use .assign() to only add properties from
newItems
and not delete missing items.
Parameters
- newItems
{Array|Object}
:A list or array of values, or an object of properties.