JavaScript/constructor:修订间差异
来自康健生活
| 第43行: | 第43行: | ||
true.constructor===Boolean; | true.constructor===Boolean; | ||
Symbol().constructor===Symbol; | Symbol().constructor===Symbol; | ||
new Map().constructor===Map; | |||
new Set().constructor===Set; | |||
var puz = new Promise((resolve,reject)=>{}); | |||
puz constructor===Promise; | |||
var xyz = new Proxy({},{}); | |||
xyz.constructor===Proxy | |||
</syntaxhighlight>|{{consoleout|<pre> | </syntaxhighlight>|{{consoleout|<pre> | ||
true | true | ||
| 第58行: | 第64行: | ||
true | true | ||
true | true | ||
true | |||
true | |||
true | |||
false | |||
</pre>}}}} | </pre>}}}} | ||
== 继承 == | == 继承 == | ||
2020年6月26日 (五) 06:45的版本
引言
constructor 是一种用于创建和初始化class创建的对象的特殊方法。[1]
constructor([arguments]) { ... }
验证
constructor 属性返回对创建此对象的数组函数的引用。
判断
继承
兼容版本
| pc | mobile | server | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 49 | 13 | 45 | NO | 36 | 9 | 49 | 49 | 45 | 36 | 9 | 5.0 | 6.0.0 |
- ↑ constructor-JavaScript|MDN[EB/OL].https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Classes/constructor
No categories