I want to convert the
window.screenattributes and values into a string to send to the back-end. (I could extract the values for each attribute but curious to understand why the below fails)Not sure why
JSON.stringify(window.screen)returns"{}".Note that the manually created object
orientation_appears to convert JSON to string fine.
- Experimenting further, I tried copying the object and then deleting the
__proto__object thinking this might be failing the conversion to string. But strangely I am unable to delete any of the keys!
Update #1:
Based on below tips that circular reference could be the issue...
Here we see that variable ahas a circular reference to itself. Using Flatted(circular JSON parser) we seeagets converted into String butwindow.screenstill doesn't convert.Based on the docs JSON.stringify(), functions are stringified as
null.So functions are not the problem.
So still not clear on the reason for this behavior.


