var john = {
fullName: 'John Smith',
mass: 230 / 2.2,
height: 1.5
calcBmi: function(bmi) {
this.johnBmi = this.height * this.height / this.mass;
}
}
你错过了高度后面的逗号。代码变为(为了可读性(:
var john = {
fullName: 'John Smith',
mass: 230/2.2,
height: 1.5,
calcBmi: function(bmi) {
this.johnBmi = this.height * this.height / this.mass;
}
};
你错过了高度后面的逗号。
var john = {
fullName: 'John Smith',
mass: 230 / 2.2,
height: 1.5,
calcBmi: function(bmi) {
this.johnBmi = this.height * this.height / this.mass;
}
}
现在试试这个。