class Cell { value = 3; parent:Cell|undefined=undefined; } function read(items:Cell[]):number { let sum=0; for(let i=0;ivoid):number { let sum=0; for(let i=0;i{mutable.length=0;}),mutable.length); const captured:(()=>number)[]=[]; for(let i=0;icell.value);} items.length=0; console.log(captured[0]!(),captured[1]!()); function readProperties(items:Cell[],indices:number[]):number { let sum=0; for(const index of indices){const cell=items[index];if(cell)sum+=cell.value;} return sum; } const properties:Cell[]=[]; properties[0]=parent; properties[2]=child; properties[1048577]=child; properties[-1]=parent; properties[0.5]=child; properties[NaN]=parent; properties[Infinity]=child; console.log(readProperties(properties,[0,-0,1,2,3,1048577,1048578,-1,0.5,NaN,Infinity]));