I had an array of data that I wanted to create a sub-list of elements starting from and index, i
, to a range. You can do this by calling array.slice
:
“Extracts a section of the array and returns the new array”
https://www.tutorialsteacher.com/typescript/typescript-array
Typescript, or the underlying Javascript also has a function that adds or removes elements from an array. This is called array.splice
:
Adds or removes elements from the array
https://www.tutorialsteacher.com/typescript/typescript-array
I suppose I don’t need to go into detail about what caused me to write this blog post, but I have some lessons:
I’d also like to call out the concept of immutability. This would have saved a stupid developer from a stupid mistake.