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
*/
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12272649.html
未经授权禁止转载,违者必究!