Could someone please explain why this doesn't work and populates the array with "circular object Array"s when there are no circular references? I know there are a million ways to do this better, and I do not plan on using this code, but I really want to know why it doesn't work. I know it must have something to do with how JS passes references, but am confused on what limit we are hitting here.
const sub = [{1: 2}, {3: 4}, {5: 6}]
const sub2 = [{7: 8}, {9: 0}, {11: 12}]
const sub3 = [{12: 13}, {14: 15}, {16: 17}]
const o = [ {label: 'a', submenu: sub}, {label: 'b', submenu: sub2} ]
console.log(o)
o.forEach((currentValue, index, arr) => {currentValue.click = sub3})
console.log(o)