Ask when to use JSON.parse(JSON.stringify(data))
Generally used to deep copy a json object, it can also be used to remove attributes whose values ??do not have JSON representation (numbers, strings, logical values, arrays, objects, null), that is to say attributes like undefined and function value.
a: {
age: 1,
name: undefined,
time: () => {...}
}
變成:
b: {
age: 1
}
Two usage scenarios:
1. Convert JSON string to JSON object, JS direct attribute reference
2. Clone object