Programming Tips - jQuery: how can I clone an object?

Date: 2017nov17 Language: javaScript Library: jQuery Keywords: copy, duplicate Q. jQuery: how can I clone an object? A. Use jQuery's extend() like this:
function shallowClone(obj) { return $.extend({}, obj); }
function deepClone(obj) { return $.extend(true, {}, obj); }
function clone(obj) { // A reasonable default return deepClone(obj); }
Example use:
let newObj = clone(oldObj);