Native deep cloning is available in the browser. You just have to hack your way to it. The below pseudo-code gives the general idea... It might work but was just typed out here so maybe has typos ? 🤷♂️ (You can also use window.postMessage if you're on an ancient browser without MessageChannel support)
function clone(toClone) {
return new Promise((yay, nay) => {
const { port1, port2 } = new MessageChannel();
port1.onmessage = ({ data }) => yay(data);
port2.postMessage(toClone);
});
}
clone({a:1}).then(a => console.log(a));
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Native deep cloning is available in the browser. You just have to hack your way to it. The below pseudo-code gives the general idea... It might work but was just typed out here so maybe has typos ? 🤷♂️ (You can also use window.postMessage if you're on an ancient browser without MessageChannel support)