-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array construction with spread syntax and map doesn't work #546
Comments
Your pattern should definitely work but how about using |
@seveves That's a really nice way to do it too :) |
I'm having the same problem while trying to create a range of numbers using this pattern: const minNumber = 1;
const maxNumber = 10;
const rangeArr = [...Array(maxNumber - minNumber + 1)].map(
(item, index) => index + minNumber
);
console.log(rangeArr); returns
Instead of
Tried the same pattern in other platforms and they work correctly:
Using @seveves pattern works correctly: const minNumber = 1;
const maxNumber = 10;
const rangeArr = Array.from(
{ length: maxNumber - minNumber + 1 },
(item, index) => index + minNumber
);
console.log(rangeArr); |
A seemingly related issue is how spreading works in general. It seems that however Stackblitz is doing compilation, it's in some sort of very loose mode that IMO is way too lose for something like Stackblitz. e.g. My guess is its maybe its using an old version of babel's loose mode--the latest versions of loose mode don't seem to do this but it might have in the past. |
Good catch everyone, thanks for reporting this! Thankfully it should no longer be an issue :) |
I use this syntax quite a lot to create my Arrays
But on your platform the array has the good size but of "undefined" element.
See here : https://stackblitz.com/edit/js-mtffex
The text was updated successfully, but these errors were encountered: