Just one thing, in the copy array example, the spread operator does a shallow-copy. It will copy things like strings, numbers, but not objects or other arrays:
letobj1={name:'test'};letobj2={name:'test2'};letarray=[obj1,obj2];letcopy=[...array];array[0]===copy[0]// true// Or if you modify copy, it will affect the original items in `array` copy[0].name='Other name';array[0].name// 'Other name'
This can lead to some weird behaviour, and some tricky bugs. I've had some problems with this in the past, and it took a while to fix. Just a thing to notice!!
Nice list, quite complete.
Just one thing, in the copy array example, the spread operator does a shallow-copy. It will copy things like strings, numbers, but not objects or other arrays:
This can lead to some weird behaviour, and some tricky bugs. I've had some problems with this in the past, and it took a while to fix. Just a thing to notice!!
But it's not a big deal, and a simple fix!
Oh this can lead to some problems, yes. I didn't know that. Thanks for sharing this 👍