1class Person { 2 constructor(name) { 3 this.name = name 4 } 5} 6 7const member = new Person("John") 8console.log(typeof member)
本题为"单选题"
参考答案:
正确选项:C:"object"
类是构造函数的语法糖,如果用构造函数的方式来重写Person
类则将是:
1function Person() { 2 this.name = name 3}
通过new
来调用构造函数,将会生成构造函数Person
的实例,对实例执行typeof
关键字将返回"object"
,上述情况打印出"object"
。
最近更新时间:2021-07-03
题库维护不易,您的支持就是我们最大的动力!