Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON

时间:2023-03-09 06:25:26
Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON

Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON

var obj = {
a: "foo",
};
// undefined obj;
//{a: "foo"} obj.b = obj;
// {a: "foo", b: {…}} JSON.stringify(obj); /*
VM205:1 Uncaught TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
--- property 'b' closes the circle
at JSON.stringify (<anonymous>)
at <anonymous>:1:6
*/

Object.stringify 循环引用 bug & TypeError: Converting circular structure to JSON