typeof运算符
手写深拷贝
function deepClone(obj){var array=Array.isArray(obj)?[]:{}//if(obj instanceof Array) {var array=[]}//else {var array={} }if(typeof obj !==\'object\' || obj==null){return obj}for (let key in obj){if(obj.hasOwnproperty(key)){array[key]=deepClone(obj[key])}else{array[key]=obj[key]}}return array}var a=[1,2,3,4];var b=deepClone(a);b[2]=5;console.log(a,b)
运行结果