JSFiddle - React, Tailwind, and code Playground
JavaScript
var x = {
a: 5,
b: "asdf"
};
var y = {
a: 5,
b: "asdf"
};
x.y = y;
y.x = x;
Object.prototype.clonage = function() {
var newObj = (this instanceof Array) ? [] : {};
for (i in this) {
if (i == 'clone') continue;
if (this[i] && typeof this[i] == "object") {
newObj[i] = this[i].clonage();
} else newObj[i] = this[i]
} return newObj;
}
var z = x.clonage();
alert (z);