Here is the deepClone function which handles all primitive, array, object, function data types
function deepClone(obj){_x000D_
if(Array.isArray(obj)){_x000D_
var arr = [];_x000D_
for (var i = 0; i < obj.length; i++) {_x000D_
arr[i] = deepClone(obj[i]);_x000D_
}_x000D_
return arr;_x000D_
}_x000D_
_x000D_
if(typeof(obj) == "object"){_x000D_
var cloned = {};_x000D_
for(let key in obj){_x000D_
cloned[key] = deepClone(obj[key])_x000D_
}_x000D_
return cloned; _x000D_
}_x000D_
return obj;_x000D_
}_x000D_
_x000D_
console.log( deepClone(1) )_x000D_
_x000D_
console.log( deepClone('abc') )_x000D_
_x000D_
console.log( deepClone([1,2]) )_x000D_
_x000D_
console.log( deepClone({a: 'abc', b: 'def'}) )_x000D_
_x000D_
console.log( deepClone({_x000D_
a: 'a',_x000D_
num: 123,_x000D_
func: function(){'hello'},_x000D_
arr: [[1,2,3,[4,5]], 'def'],_x000D_
obj: {_x000D_
one: {_x000D_
two: {_x000D_
three: 3_x000D_
}_x000D_
}_x000D_
}_x000D_
}) )
_x000D_