当我编写JavaScript时,我经常会忘记一些内置对象的属性,不得不在mdn中查找它们,这很麻烦,因为它会减慢我的工作速度。与其参考文档,更方便的方法是创建一个对象,并使用
for ... in
结构和console.log()
来检查它。但是对于非枚举属性,即使使用for ... in
也无济于事。所以我的问题是,除了谷歌和文档,是否有其他方法来检查非枚举属性?for(var i in Object){
console.log([i,Object[i]]);
// ["wtbind", function()]
}
console.log(Object.hasOwnProperty('create'));
// true
// Here Object.create is a non–enumerable property,
// and I have to look it up in documents if I forget it.
console.dir()
而不是console.log()
吗? - lanzzconsole.dir()
。我尝试了console.dir(Object);//shows "prototype Object{}"
,但是那些非枚举属性,比如Object.create没有出现。 - OpenGG.toSource()
产生任何影响。 - OpenGG