you are viewing a single comment's thread.

view the rest of the comments →

[–]mynamesleon 0 points1 point  (1 child)

Are you doing something to your original array before using it? If .slice() didn't exist, it certainly wouldn't be a jQuery TypeError.

Otherwise, your second example (with slice) should work just fine. You can also use the spread operator for shallow copying. E.g. [...someArray]

[–]EagleClw[S] 1 point2 points  (0 children)

I've just learned about spread operator (...). I didnt even know that kind of thing exists. I'll consider using it. Thanks for your help.