最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why JSON.stringify() returns empty result for some objects - Stack Overflow

programmeradmin2浏览0评论

This question is so basic, yet I have no idea of the answer.

Why screen object when stringified returns empty?

Does this mean JSON.stringify() needs read/write access to the input?

let a = {foo: 'one', bar: 2};


console.log(JSON.stringify(a));
console.log(JSON.stringify(screen));

This question is so basic, yet I have no idea of the answer.

Why screen object when stringified returns empty?

Does this mean JSON.stringify() needs read/write access to the input?

let a = {foo: 'one', bar: 2};


console.log(JSON.stringify(a));
console.log(JSON.stringify(screen));

Share Improve this question edited Jul 27, 2018 at 11:30 Lemures asked Jul 27, 2018 at 11:07 LemuresLemures 4825 silver badges11 bronze badges 4
  • 1 @Variable developer.mozilla/en-US/docs/Web/API/Window/screen . If it was never declared you'd get an error about it being undefined. – ADyson Commented Jul 27, 2018 at 11:10
  • 7 Possible duplicate of Stringify DOMWindow object – user202729 Commented Jul 27, 2018 at 11:11
  • @ADyson Thanks, didn't knew about this, learned something new :D.
发布评论

评论列表(0)

  1. 暂无评论