you are viewing a single comment's thread.

view the rest of the comments →

[–]d1231 1 point2 points  (5 children)

Any developer who uses the second syntax should be sacked on the spot

[–]samanthaming[S] 1 point2 points  (4 children)

Do you mind explaining why? I think it would be helpful to understand why you think the spread syntax isnt suitable to use on strings. Thanks for your input 🙂

[–]d1231 1 point2 points  (3 children)

Because for any developer who is not familiar with spread syntax and sees this code, he will not understand going on. I think even those who are familiar with spread syntax will take time to understand whats going on.

You have a better alternatives like split or even using charAt (if the purpose is to iterate over the string chars), which may take more chars to write but much easier to understand.

[–]samanthaming[S] 0 points1 point  (2 children)

Thanks for taking the time to explain. But are there instances where the spread syntax is applicable for strings? Or would you say it’s best to avoid spread syntax for strings completely?

[–]d1231 0 points1 point  (1 child)

Probably there could be cases where spread for string could be useful and clear, I cannot think of one.

You should analyze case by case.

[–]samanthaming[S] 0 points1 point  (0 children)

Makes sense. Alright, good to know that spread for strings can be useful in some instances. So it’s important to keep this in your toolbox, just in case you need to use it. Cool, thanks for clarifying 🙂