assign
Sets values within a list or properties on a list.
list.assign(newItems)
If newItems
is list like the values in newItems
will replace the indexed value in the list
. For example:
import { DefineList } from "can";
const list = new DefineList(["A","B"]);
list.assign( ["a"] );
console.log( list.serialize() ); //-> ["a","B"]
NOTICE:
.assign()
will not remove properties in the list that have indexes greater than or equal to thenewItem
's length. Use .update() to replace all of a list's values.
If newItems
is an object, the object's properties will be added as properties to
the list
. For example:
import { DefineList } from "can";
const list = new DefineList(["A","B"]);
list.assign( {count: 1000, skip: 2} );
console.log( list.count ); //-> 1000
Parameters
- newItems
{Array|Object}
:A list or array of values, or an object of properties.