Node.js console.log(object) prints empty object

前端 未结 1 935
野趣味
野趣味 2021-01-18 09:26

I\'m curious about the way Node.js prints objects through console.log(object).

I have the following code (from Learning Javascript Design Patterns book) under a fil

1条回答
  •  囚心锁ツ
    2021-01-18 09:44

    console.log() in node utilizes util.inspect(), which uses Object.keys() on objects, which returns only own enumerable properties. Also, by default, Object.defineProperty() sets enumerable: false if you do not explicitly set it to true.

    0 讨论(0)
提交回复
热议问题