function Person {} Person.prototype.test = function() { }
new Person()
new Person
这两种写法有相同的效果,不加括号为什么和前一个效果一样
new constructor[([arguments])]
当代码 new Person(...) 执行时:
一个新对象被创建。它继承自Person.prototype.构造函数 Person 被执行。执行的时候,相应的传参会被传入,同时上下文(this)会被指定为这个新实例。
new Person 等同于 new Person(), 只能用在不传递任何参数的情况。
2.1m questions
2.1m answers
62 comments
56.6k users