构建对象并向数组中添加对象

 1     //数组的两种定义方式,构造函数new或者数组直接量。
 2     //构造函数,构造对象
 3     function objStory(id,title,author,time){
 4         this.ID = id;
 5         this.Title = title;
 6         this.Author = author;
 7         this.Time = time;
 8 
 9     }
10     var arr = [];
11     arr.push(new objStory(10,"woshiwang","king","2012-01-03"));
12     arr.push(new objStory(12,"wang","los","2012-01-04"));
13     console.log(arr);

 

posted @ 2017-02-06 10:17  武侯668  阅读(1682)  评论(0编辑  收藏  举报