Copying JavaScript object and arrays

I recently learned this method:

Copying a JavaScript Object

const source = { a: 1, b: 2 };
const copy = Object.assign({}, source);

Copying a JavaScript Array

const arr = [0,2,3,4,5];
const arrCopy = arr.slice(0);

These two functions come handy when you don't want to modify the source object/array and need a copy instead.