set
Sets an item or property or items or properties on a list.
Deprecated 3.10.1
Using .set with {Object} props
has been deprecated in favour of assign
and update
list.set(prop, value)
Sets the property at prop
. This should be used when the property
isn't already defined.
var list = new DefineList(["A","B"]);
list.set("count",1000);
list.get("count") //-> 1000;
Parameters
- prop
{Number}
:A property name.
- value
{*}
:The value to add to the list.
list.set(newProps)
Updates the properties on the list with newProps
.
var list = new DefineList(["A","B"]);
list.set({count: 1000, skip: 2});
list.get("count") //-> 1000
Parameters
- newProps
{Object}
:An object of properties and values to set on the list.
list.set(index, value)
Sets the item at index
. Typically, splice should be used instead.
var list = new DefineList(["A","B"]);
list.set(2,"C");
Parameters
- index
{Number}
:A numeric position in the list.
- value
{*}
:The value to add to the list.
list.set(newItems [,replaceAll])
Replaces items in the list with newItems
var list = new DefineList(["A","B"]);
list.set(["c"]) //-> DefineList["c","B"]
list.set(["x"], true) //-> DefineList["x"]
Parameters
- newItems
{Array}
:Items used to replace existing items in the list.
- replaceAll
{Boolean}
:If true, will remove items at the end of the list.