Object.prototype returns empty object in Node

后端 未结 2 915
误落风尘
误落风尘 2021-02-18 16:50

While I execute Object.prototype in browser console, i am getting all the properties and methods available inside Object.prototype. This is as expected

2条回答
  •  孤城傲影
    2021-02-18 17:50

    By the way, you can use Object.getOwnPropertyNames if you want to know or access these properties.

    > Object.getOwnPropertyNames(Object.prototype)
    [ 'hasOwnProperty',
      'constructor',
      'toString',
      'toLocaleString',
      'valueOf',
      'isPrototypeOf',
      'propertyIsEnumerable',
      '__defineGetter__',
      '__lookupGetter__',
      '__defineSetter__',
      '__lookupSetter__',
      '__proto__' ]
    

    It won't list other properties you might find in chrome dev console like scope or the value of promises. But it's good enough!

提交回复
热议问题