【文件属性】:
文件名称:proposal-object-has:ECMAScript的Object.has()建议
文件大小:20KB
文件格式:ZIP
更新时间:2021-04-06 12:35:43
HTML
Object.has()
建议使用Object.has()方法以使Object.prototype.hasOwnProperty()更易于访问。
地位
这项建议尚未引入TC39。
作者:
(Jamie Kyle,Discord)
冠军: (Tierney ,微软)
幻灯片:
动机
如今,编写如下代码非常普遍(尤其是在库代码中):
let hasOwnProperty = Object . prototype . hasOwnProperty
if ( hasOwnProperty . call ( object , "foo" ) ) {
console . log ( "has property foo" )
}
该建议将该代码简化为:
if ( Object . has ( object , "foo" ) ) {
console . log ( "has
【文件预览】:
proposal-object-has-main
----index.html(53KB)
----.gitattributes(87B)
----.github()
--------workflows()
----polyfill.js(287B)
----spec.emu(1KB)
----LICENSE(1KB)
----README.md(4KB)
----.npmrc(19B)
----.gitignore(696B)
----package.json(568B)