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>