Replace spread operator with split() for increased performance and compatibility

This commit is contained in:
Wojciech Maj
2017-12-18 00:41:26 +01:00
parent 078de0a951
commit b2e12335f8

View File

@ -2,10 +2,10 @@
Reverses a string. Reverses a string.
Use array destructuring and `Array.reverse()` to reverse the order of the characters in the string. Use `split('')` and `Array.reverse()` to reverse the order of the characters in the string.
Combine characters to get a string using `join('')`. Combine characters to get a string using `join('')`.
```js ```js
const reverseString = str => [...str].reverse().join(''); const reverseString = str => str.split('').reverse().join('');
// reverseString('foobar') -> 'raboof' // reverseString('foobar') -> 'raboof'
``` ```