3 ms·
If `thing` contains any cycles then it will explode. E.g. const thing = {}; thing.self = thing; or const thing = []; thing.push(thing); If t
by Thiez 3y ago
If `thing` contains any cycles then it will explode. E.g.
const thing = {};
thing.self = thing;
or
const thing = [];
thing.push(thing);
If this sounds far-fetched to you just know that all DOM elements have these circular references through (for example) parent / child references.
Also any non-enumerable properties that may have been defined on objects are lost.
Basically the function is only suitable for recently parsed JSON.
- adriaanmulder 3y agoThat's a great point