I am writing an Array-derived class in JavaScript and need to know which functions to overload so that I can be aware of changes made to the array.
I know Array.push() and Array.splice() are mutating. Is there a definitive list of any others?
I am writing an Array-derived class in JavaScript and need to know which functions to overload so that I can be aware of changes made to the array.
I know Array.push() and Array.splice() are mutating. Is there a definitive list of any others?
I found this website called Doesitmutate
Have the list of all functions - and tells whether it mutates or not.
You can also use .concat(), before using your mutation method, to ensure you are not mutating your arrays, eg
const dontMutateMe = [4,5,1,2,3];
const sortArray = dontMutateMe.concat().sort(...)
const sortArray = [ ...dontMutateMe ].sort(...);const sortArray = dontMutateMe.concat() create a new array just as const sortArray = [ ...dontMutateMe ] would?