选择题1537/1620输出什么?

1class Person { 2 constructor(name) { 3 this.name = name 4 } 5} 6 7const member = new Person("John") 8console.log(typeof member)
难度:
2021-07-02 创建

本题为"单选题"

参考答案:

正确选项:C:"object"

类是构造函数的语法糖,如果用构造函数的方式来重写Person类则将是:

1function Person() { 2 this.name = name 3}

通过new来调用构造函数,将会生成构造函数Person的实例,对实例执行typeof关键字将返回"object",上述情况打印出"object"

最近更新时间:2021-07-03

赞赏支持

题库维护不易,您的支持就是我们最大的动力!