As spread operator acts as if we used String[Symbol.iterator], it is better to use spread operator instead of regular String.prototype.split to split given string into characters when the string may involve Unicode characters. It's not foolproof, but better.
For example,
As spread operator acts as if we used String[Symbol.iterator], it is better to use spread operator instead of regular
String.prototype.split
to split given string into characters when the string may involve Unicode characters. It's not foolproof, but better.For example,
So, if you get asked to reverse a string with JS in an interview, following might be treated as too naive:
Following is slightly better: