It was such a headslapping moment when I realized the spread operator can work on strings. Not sure if useful, but still pretty cool.

I use the spread operator all day, every day like it’s going out of style. One thing I didn’t know was it’s not just for arrays and objects. Checkout the MDN here too about it Spread syntax (…), how did I miss it?

Spread syntax (…) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.”

I’m not sure when I’ll actually need to use this over split(), but it’s still cool to know about it.

Leave a Reply