JS构造函数中返回不同的类型,使用 new 关键字 会创建什么样的实例?
1、构造函数中如果没有返回值
var Foo = function() {
}
Foo.prototype.a = () => {
console.log("a") }
var foo = new Foo();
console.log(foo)
foo.a()
![image-20201123192826632](https://i-blog.csdnimg.cn/blog_migrate/cd9e671a7ae3e44ce48e088d28056a5c.png)
返回 Foo
的实例,可以调用 原型上的方法
2、构造函数中返回 原始类型 数据
var Foo = function() {
return true
}
Foo.prototype.a = () => {
console.