这里可以实现类对象数组。方便自己存储和封装数据用。
1 function MyClass() {
2 this.myData = 5;
3 this.myString = "Hello World";
4 }
5
6 var myClassObj1 = new MyClass();
7 var myClassObj2 = new MyClass();
8 myClassObj1.myData = 10;
9 myClassObj1.myString = "Obj1: Hello World";
10 myClassObj2.myData = 20;
11 myClassObj2.myString = "Obj2: Hello World";
12
13 var array = Array();
14 array[0] = myClassObj1;
15 array[1] = myClassObj2;
16
17 for (i = 0; i < array.length; i++) {
18 alert(array[i].myData);
19 alert(array[i].myString);
20 }
posted on 2006-11-29 11:57
rox 阅读(994)
评论(0) 编辑 收藏 所属分类:
AJAX