score:10

Accepted answer

you can use array spread or array.concat() to make a shallow clone, and add new items as well):

const state = {
  foo: ['bar']
};

const copy = [...state.foo, 'bar'];

console.log(copy === state.foo); // false


Related Query

More Query from same tag