Why does the following piece of code lead to "Type Error: Converting Circular Structure to JSON" in Chrome console ?
JSON.stringify(document.querySelectorAll("img")) Why does the following piece of code lead to "Type Error: Converting Circular Structure to JSON" in Chrome console ?
JSON.stringify(document.querySelectorAll("img")) A DOM element contains circular references and you can't call JSON.stringify() on any object that contains circular references or contains objects with circular references.
For example, it contains .parentNode which then contains .childNodes which then points right back to the same element. As soon as JSON.stringify() detects such a circular reference, it stops because it can't record all the properties.
Basically, you can't stringify a DOM node or a list of DOM nodes. Perhaps if you help us understand what problem you're really trying to solve, we can help with an alternative way of doing this. For example, maybe all you need to save it the img.src property in order to save these images.