Home | Mailing List | Blog | Tutorial Videos

Spread and Rename

Consider the following array of objects... okay, well one object. What happens when we spread that array and change the firstName property on the 0-index object?

const arr1 = [{ firstName: 'James' }];
const arr2 = [...arr1];
arr2[0].firstName = 'Jonah';

console.log(arr1);

Select one: