object rectangle 目的矩形
Then define a function which computes the area for the rectangle object.
然后定义一个函数来计算Rectangle的面积。
Here every Rectangle object created will have three properties - height, width and area.
在这里矩形对象中会有会个属性,height, width和area。
Hence prototype object is the best place to define methods like area which remain the same for all Rectangle objects.
因此prototype对象是一个最理想地方来存储像area这个所有对象都相同的属性。
应用推荐