There's better ways to clone and append to an array than splice. Splice actually mutates the original array and I use it mainly to remove an element from an array. Could you explain why you want to use splice? For the sake of experimenting? With ES6 you can initiate a new array and use spread to create such an array.
Yeah I was just trying to better understand it’s functionality and this seemed like a small enough experiment to test the potential implementation. Definitely agree that your example using the spread operator is a much more practical approach.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There's better ways to clone and append to an array than splice. Splice actually mutates the original array and I use it mainly to remove an element from an array. Could you explain why you want to use splice? For the sake of experimenting? With ES6 you can initiate a new array and use spread to create such an array.
Yeah I was just trying to better understand it’s functionality and this seemed like a small enough experiment to test the potential implementation. Definitely agree that your example using the spread operator is a much more practical approach.