• 0

push vs concat vs spread

push, concat and spread all of them are object/array manipulation methods.

push - mutates the original data

var a = [1, 2, 3];
a.push(9); // returns 4
console.log (a); // [1, 2, 3, 9]

concat - returns new array and does not mutate the original data

var a = [1, 2, 3];
a.concat(9); // returns [1, 2, 3, 9]
console.log(a); // returns [1, 2, 3]

spread - nicer way to use concat, does not mutate the original data

var a = [1, 2, 3];
console.log([...a, 9]); // returns [1, 2, 3, 9]