Add item ( object, integer, string, bool etc. ) to an array:
const { addToArray } = require('simple-immutability-helpers');
const array = [1, 2, 3, 4];
const newArray = addToArray(array, 5)
// returns a new array containing [1, 2, 3, 4, 5]
Remove an item from an array
const { removeFromArray } = require('simple-immutability-helpers');
const array = [{ name: 'Jack' }, { name: 'Tom' }];
const newArray = removeFromArray(array, { name: 'Tom' })
//returns a new array, [{ name: 'Jack' }]
Clone an array
const { clone, cloneDeep } = require('simple-immutability-helpers');
const array = [1, 2, 3];
const clonedArray = clone(array)
//returns a new array, [1, 2, 3]
const nestedObject = { name: 'Jack', favoriteFood: ['Pizza', 'Steak'] }
const clonedNestedObject = cloneDeep(nestedObject);
//returns a deep clone of the object, { name: 'Jack', favoriteFood: ['Pizza', 'Steak'] }