DEV Community

Discussion on: You don't know spread operator !

ca0v profile image
Corey Alix

Why is it dangerous?

parsyvalentin profile image
Valentin PARSY Author

The Number primitive wrapper object is used EVERYWHERE. If you change anything that "low-level" in your code, it will change it everywhere in your code/app, potentially changing the behavior of (in this example) every Number you use.

As a solution you could have your own IterableNumber, that is a Number to which you set the Symbol.iterator property. (not sure it is a good solution though)

loclv profile image

I think there are a case to be made teammate (include me) confused.

a = 8
// output 🚀: [1, 2, 3]

// now set it's value again
a = 's'
// output 🚀: ['s']
Enter fullscreen mode Exit fullscreen mode