.push()
and .splice()
directly modify the array.concat()
doesn’t modify array but just returns a new array.slice()
doesn’t modify array but just returns a new array[…array]
doesn’t modify array but just returns a new array[...array.slice(0, index), ...array.slice(index + 1, array.length)]
arrray.slice(0, index).concat(array.slice(index + 1, array.length));
array.filter((_, i) => i !== index);
Take a target object and source objects and map properties from the source objects to the target object. Any matching properties are overwritten by properties in the source objects.
const newObject = Object.assign({}, obj1, obj2);