Create a deep clone of any JSON-serializable object via JSON.parse(JSON.stringify(…)). Safe for plain chart data objects. Does not preserve class instances, undefined, Infinity, NaN, or circular references.
JSON.parse(JSON.stringify(…))
undefined
Infinity
NaN
const copy = deepClone(chart.judgeLineList[0]);copy.Name = 'Clone'; // original is unchanged Copy
const copy = deepClone(chart.judgeLineList[0]);copy.Name = 'Clone'; // original is unchanged
Create a deep clone of any JSON-serializable object via
JSON.parse(JSON.stringify(…)). Safe for plain chart data objects. Does not preserve class instances,undefined,Infinity,NaN, or circular references.