Consider this code which creates a sequence of links to (not copies from) elements in the items array -
class Item { constructor(text) { this.text = text; }}
let items = [new Item ('a'), new Item ('b'), new Item ('c'), new Item ('a')]
let sequence = [items[0], items[3], items[1]]
console.log(sequence[2].text); //'b'
Let's prove that sequence is linked to (not copied from) elements in the items array -
items[1].text= 'bb';
console.log(sequence[2].text); //'bb'
From visual inspection of the code, we see that sequence[1] is linked to items[3].
console.log(sequence[1].text); //'a'
How could we programmatically determine which index of items that an element of sequence is linked to ? For example sequence[1] is linked to index 3 of the items array.