I'm learning react from a book and in an example the author made a component render this way
return (
<div className="star-rating">
{[...Array(totalStars)].map((n,i)=>
<Star key = {i} selected={i<starSelected} onClick={()=>this.change(i+1)} />
)}
<p>{starsSelected} of {totalStars} stars </p>+
)
What purpose does the spread element serve here when initializing the array?