The deep copy of typescript is stuck in an endless loop, how to modify the code? Solve it! Thank you

deepCopy (data: any) {

let t = this.type(data),
  o: any,
  i,
  ni;
if (t === "array") {
  o = []; //
} else if (t === "object") {
  o = {}; //
} else {
  return data;
}
if (t === "array") {
  //console.log("t:%o,data:%o", t, data);
  for (i = 0, ni = data.length; i < ni; iPP) {
    o.push(this.deepCopy(data[i]));
  }
  return o;
} else if (t === "object" ) {
  //console.log("t:%o,data:%o", t, data);
  for (i in data) {
    if(data[i]===data){
      continue;
    }
    o[i] = this.deepCopy(data[i]);
  }
  return o;
}

}
type (obj: any) {

var toString = Object.prototype.toString;
var map = {
  "[object Boolean]": "boolean",
  "[object Number]": "number",
  "[object String]": "string",
  "[object Function]": "function",
  "[object Array]": "array",
  "[object Date]": "date",
  "[object RegExp]": "regExp",
  "[object Undefined]": "undefined",
  "[object Null]": "null",
  "[object Object]": "object"
};
return map[toString.call(obj)];

}

Mar.25,2022

is really a problem caused by circular references. After watching https://codeshelper.com/a/11..., thank you for sharing!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eae1fe-21b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eae1fe-21b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?