ReadonlyArray (TS)
JS
S
JavaScriptPrevent all array mutations with `ReadonlyArray`
1let myArray: ReadonlyArray<number> = [1, 2, 3];
2
3foo.push(4); // Error: `push` does not exist on ReadonlyArray as it mutates the array
4foo = foo.concat([4]); // Okay: create a copy
5foo[0]=2; // Error
6Created on 7/15/2019