1// only works with pure JSON data (bool, numbers, strings, arrays, nested
2// objects; No functions).
3var obj2 = JSON.parse(JSON.stringify(obj));
4
5// works with everything, requires lodash library, faster than previous answer
6var obj2 = _.cloneDeep(obj, true);
7
8// shallow copy
9var obj2 = Object.assign({}, obj);