Consider the following examples
An old project:
const [x, ...y] = "text";
console.log(x) // "t"
console.log(y) // "ext"
A new project based on CRA:
const [x, ...y] = "text";
console.log(x) // "t"
console.log(y) // ["e", "x", "t"]
I'm not sure why y
is returning a string ("ext"
) for the old project, where it's an array of characters (["e", "x", "t"]
) for the new project. Is it something to do with different JS versions?
Note: Both result were extracted after running webpack dev server.
in babel website you can see that your code based on es2015-loose convert to this code so output of this code is same with your old project