Array:
1. slice()
const newAry = ary.slice()
2. concat
const newAry = [].concat(ary)
3. spread opreator:
const newAry = [...ary]
4. Array.from:
const newAry = Array.from(ary)
Object:
Shadow copy:
1. object.assign:
const newObj = Object.assign({}, obj, {prop: 'newProp'})
2. spread opreator:
const newObj = { ...obj }
Deep copy:
From lodash:
const newObj = _.cloneDeep(obj)
From Ramda:
const newObj = R.clone(obj);
JS:
const newObj = JSON.parse(JSON.stringify(obj))