class returns Nan 中数字属性的乘法

Multiplication of Number Properties in class returns Nan

我在 chrome 中为 JavaScript Class 尝试了下面的示例代码,即使两个属性的数据类型都是 Number,我得到的输出也是 Nan。

class Sample
{
constructor(height,width)
{
    this.height = height;
    this.width = width;
}

calcArea()
{
    console.log ("Height : " + this.height + " Type : " + typeof this.height);
    console.log ("Width : " + this.width + " Type : " + typeof this.width);
    console.log( this.height * this.Width);
}
} 
var objSample = new Sample(10,20);
objSample.calcArea();

请在下面找到我在控制台中得到的输出。谢谢

Height : 10 Type : number
Width : 20 Type : number
NaN

您的计算出现大小写错误。你在应该 this.height * this.width

的时候做了 this.height * this.Width