js学习随感随记

function rectangle(w,h)函数

{this

this.width=w;对象

this.height=h;io

}function

这里是声明一个函数能够返回this属性里的长和高new

用new能够建立新的对象而不影响前一个的值

var rect1=new rectangle(2,5);

var rect2=new rectangle(5,7);

这样rect1和rect2的高度宽度就都分别为上述()中的值了

相关文章
相关标签/搜索