标签:
构建对象的方法
<script> //构建对象方法 //第1种 var people = new Object(); people.name = "iwen"; people.age = 26; document.write("name:" + people.name + ",age:" + people.age + "<br>"); //第2种 people1 = { name: "zhangsan", age: 27 }; document.write("name:" + people1.name + ",age:" + people1.age + "<br>"); //第3种 function peopleConstructor(name, age) { this._name = name; this._age = age; } son = new peopleConstructor("liuz", 28); document.write("name:" + son._name + ",age:" + son._age + "<br>"); </script>
标签:
原文地址:http://www.cnblogs.com/tangge/p/5672907.html