Please see my computer
function computer(brand,year,owner)
{
this.brand=brand;
this.year=year;
this.owner=owner;
}
function Show(obj_name,obj)
{
var result="",i="";
document.writeln(" My computer object propties value");
for(i in obj)
result+=obj_name+"."+i+"="+obj[i]+"";//i属性名,obj[i]属性值
document.writeln(result);
}
var MyComputer=new computer("IBM",1996,"Liu");//申明对象并初始化
MyComputer.Current="Lend";//增加属性
var Ancomputer=new computer("Compaq",1997,"Yang");
Show("MyComputer",MyComputer);//显示
Show("Ancomputer",Ancomputer);
注意:
1.可以动态增加属性
2.没有继承