[英]JSON.Stringify returns empty array when Stringifying array of objects
[英]Why JSON.stringify() returns empty result for some objects
這個問題是如此基本,但我不知道答案。
為什么在stringified返回空時screen
對象?
這是否意味着JSON.stringify()
需要對輸入進行讀/寫訪問?
let a = {foo: 'one', bar: 2}; console.log(JSON.stringify(a)); console.log(JSON.stringify(screen));
來自MDN網絡
對於所有其他Object實例(包括Map,Set,WeakMap和WeakSet),只會序列化它們的可枚舉屬性。
閱讀https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
console.log((window.screen)); console.log(JSON.stringify(window.screen)); console.log(window.propertyIsEnumerable(screen));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.