除了解析构造函数之外,这两个之间有什么区别吗?
var Person = function(living, age, gender) {
this.living = living;
this.age = age;
this.gender = gender;
this.getGender = function() {
return this.gender;
};
};
var Person = function Person(living, age, gender) {
this.living = living;
this.age = age;
this.gender = gender;
this.getGender = function() {
return this.gender;
};
};
两者都可以使用
var p = new Person("Yes",25,"Male");
第一个解析为function(),后者解析为person(),但我想知道使用一个比另一个有什么优势