Does anyone have a strong understanding of how this shallow copy approach could impact a .map method? In short, what is the difference between:
Method 1:
const ratingArray = Array.from(new Array(Math.floor(rating)));
vs.
Method 2:
const ratingArray = new Array(Math.floor(rating));
in terms of their impact on this snippet:
{ratingArray.map(() => (
<SvgXml xml={star} width={20} height={20} />
))}
I've been working through a tutorial and noticed this on line 51 in this file https://github.com/mobinni/MealsToGo/blob/14-rating/src/features/restaurants/components/restaurant-info-card.component.js#L51. When playing around with them, it does seem to impact the behavior of .map, so I really don't understand what's going on under the hood here.
Wouldn't using Array.from just create an additional shallow copy? I don't understand why that is necessary, but if you use Method 2 it doesn't appear to function as expected.