mdn spread 1

mdn spread

const parts = ['shoulders', 'knees'];
const lyrics = ['head',, 'and', 'toes'];
// ["head", "shoulders", "knees", "and", "toes"]

Here is what the above code is Doing:
1. We create an array called parts with two strings in it: “shoulders” and “knees”.
2. We create an array called lyrics with three strings in it: “head”, “and”, “toes”.
3. We then use the spread operator (…) to copy each item from the parts array to the lyrics array.
4. The lyrics array now has five strings in it: “head”, “shoulders”, “knees”, “and”, “toes”.

Similar Posts