javascritpt创建对象

javascript添加对象示例:

<script>
person=new Object();
person.firstname="Bill";
person.lastname="Gates";
person.age=56;
person.eyecolor="blue";
document.write(person.firstname + " is " + person.age + " years old.");
</script>

结果:

Bill is 56 years old.

替代语法,结果相同:

<script>
person={firstname:"Bill",lastname:"gates",age:56,eyecolor:"blue"} document.write(person.firstname + " is " + person.age + " years old.");
</script>
上一篇:如何使Android应用支持多种屏幕分辨率


下一篇:ZOJ - 1586 QS Network (Prim)