ListUnit
ListUnit vs array
array// initialization
const arr = ['π ']; // an array literal
const unit = new ListUnit({initialValue: ['π ']}); // value is ['π ']
arr === unit // false
arr instanceof Array // true
unit instanceof Array // false
Array.isArray(unit) // false
// setting an item
arr[1] = 'π'
unit.set(1) = 'π' // this is reactive, creates and dispatches a new array
// pushing an item
arr.push('π')
unit.push('π') // this is reactive, creates and dispatches a new array
// accessing an item at index 0
arr[0]
unit.get(0)
// or
unit.first()
// removing an item at index 1
arr.splice(1, 1)
unit.splice(1, 1)
// or
unit.remove(1)Last updated
Was this helpful?