ES6 - Use the Spread Operator to Evaluate Arrays In-Place

Tell us what’s happening:
Not exactly have a problem but I am just wondering why bother to use the spread operator when I can just assign to arr1 to arr2 with a simple =.

Any real life examples on how the operator should be used?

Your code so far
arr2 = arr1

const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];
let arr2;

arr2 = [...arr1];  // Change this line

console.log(arr2);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: ES6 - Use the Spread Operator to Evaluate Arrays In-Place

Link to the challenge:

This means you have two variables pointing to one array

This means you have two variables, each pointing at a different array with the same contents

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.