react-live
react-live copied to clipboard
spread syntax is not supported to split a string
When attempting to split a string using the ... spread syntax, the behaviour is not consistent with JS specification:
const slicedPizza = [...'pizza'];
console.log(slicedPizza);
// expected ['p', 'i', 'z', 'z', 'a']
// actual ['pizza']
what bugs me is that the following examples behave as expected:
function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
// 6
let parts = ['shoulders', 'knees'];
let lyrics = ['head', ...parts, 'and', 'toes'];
console.log(lyrics)
// ['head', 'shoulders', 'knees', 'and', 'toes']
Can be reproduced by copying these examples in the playground
hey @mjarraya -- i haven't been able to recreate this. it may have been addressed in changes since you opened this. please can you verify that it is still an issue?