Give the class:
class Foo {
public readonly arr: number[]
constructor(arr: number[]) {
this.arr = arr
}
}
Given that arr
is readonly, the following shouldn't work:
foo.arr = [1,2]
However, can I push/pop to this arr
with:
const foo = new Foo([1,2,3])
foo.arr.pop()
foo.arr.push(4)