构造函数的返回值,几种情况:
1.没有返回值,默认返回this对象
var a = function(){
this.x=3
var y =4
a.prototype.z=5
}
var b = new a()
console.log(b) //a {x: 3}
2.有返回值,return,但是是基础值类型的,忽略,仍旧返回this
var a = function(){
this.x=3
var y =4
a.prototype.z=5
return 1
}
var b = new a()
console.log(b) //a {x: 3}
3.有返回,返回值是引用类型,则返回指定的数据
var a = function(){
this.x=3
var y =4
a.prototype.z=5
return []
}
var b = new a()
console.log(b) // []