item(index, [item])

Class: Tree.

Description:

Updates or gets an item at specified index.

Parameters:

Name Type Description

index

Array.<number>

Index of the item to get or update.

[item]

object

Item object. Omit this argument to get the item instead of updating it.

Returns:

[object|undefined|Tree] If item argument is passed, this Tree component is returned; otherwise an item at specified index is returned, or null if passed index is invalid.

Examples:

// update an item at index [0,3,5]
tree.item([0,3,5], {text:"New item text"});

// get an item at index [0,3,5]
let item = tree.item([0,3,5]);
console.log(item?.text); // checks if item is not undefined