JSFiddle - React, Tailwind, and code Playground
by shivaay123
JavaScript
let sportsmanObj = {
name: "Shiv",
age: 22,
gender: "Male"
}
sportsmanObj.myself = sportsmanObj
const circularFunc = () => {
const sited = new WeakSet();
return (key, value) => {
if (typeof value === "object" && value !== null) {
if (sited.has(value)) {
return;
}
sited.add(value);
}
return value;
};
};
JSON.stringify(sportsmanObj, circularFunc());
console.log(sportsmanObj)