I'm a beginner to JavaScript and today I learned about primitive and reference values, so I decided to write a function that can deep clone an array and objects. Is this good code or is it not good enough?function clone(o,mode){  'use strict';  mode = mode || 'deep';  var obj = {} ;  var arr = [];  if(typeof o === object){    if(Array.isArray(o)){      //is Array      if(mode!==deep){        arr =  o.slice();      }else{      for (var i = 0, len = o.length; i < len; i++) {        if(typeof o[i] === object) arr.push(clone(o[i],1));        else arr.push(o[i]);      }}      return arr;    }else{      //is Object      if(mode!==deep){        obj =  Object.assign({},o);      }else{      for (var key in o) {    // skip loop if the property is from prototype    if (!o.hasOwnProperty(key)) continue;        if(typeof o[key] === object)obj[key]=clone(o[key],1);        else obj[key]=o[key];      }}      return obj;  }}    return o;}
Deep Clone Objects
javascript