function
Person(name, height) {
this
.sayInfo =
function
() {
return
"姓名:"
+ name +
", 身高:"
+ height +
", 体重:"
+
this
.weight;
}
}
function
Chinese(name, height, weight) {
Person.call(
this
, name, height);
this
.weight = weight;
this
.nation =
function
() {
console.log(
"我是中国人"
);
}
}
function
America(name, height, weight) {
Person.apply(
this
, [name, height]);
this
.weight = weight;
}
let
chiness =
new
Chinese(
"成龙"
,
"178cm"
,
"60kg"
);
console.log(chiness.sayInfo());
let
america =
new
America(
"jack"
,
"180cm"
,
"55kg"
);
console.log(america.sayInfo());