There seems to be no native way, but it is as simple as,
functiondeepClone(o){/**
* This excludes null
*/if(o&&typeofo==='object'){if(Array.isArray(o)){returno.map((a)=>deepClone(a))}elseif(o.constructor===Object){returnObject.entries(o).reduce((prev,[k,v])=>({...prev,[k]:deepClone(v)}),{})}/**
* Now it depends on how you would recreate the Object, or not...
*/returno}/**
* BTW, function is another important case you might consider...
*/returno}
A perfect way is simply,
/**
* Yes, that dangerousLoad
* js-yaml's dump also supports several options
*/yaml.load(yaml.dump(o))
Passionate about building great technology and connecting with people to create positive change. Happy to answer questions about transitioning to tech. Find me on Twitter @lounecl
There seems to be no native way, but it is as simple as,
A perfect way is simply,
This is helpful. Thanks!!