JSFiddle - React, Tailwind, and code Playground
HTML
<div id="out">
</div>
JavaScript
function log(m) {
document.getElementById('out').innerHTML += m + '<br>';
}
var list = [1,2,3];
log('List:')
log(list);
//If we simply assign (or return) an array, and then change it,
//we can possibly cause problems elsewhere because the original list
//is affected by the action, as you'll see here, with the number 4
//showing up in the original list.
var noConcat = list;
noConcat.push(4);
log('List after not using concat and pushing:');
log(list);
//But when we concat() the array, it creates a brand new array.
//This avoids causing issues, as changing the new array has no
//effect on the original. The number 5 will not show up in the
//original array at all.
var concatenated = list.concat();
concatenated.push(5);
log('List after concatenating and pushing:');
log(list);