js declares arrays and adds object variables to arrays

Arrays can be defined in four ways 
using the constructor: 
var a = new Array(); 
var b = new Array(10); 
var c = new Array("first", "second", "third"); 
or the array directly Quantity: 
var d = ["first", "second", "third"]; 

extension:

 function ObjStory(id,biaoti,author,type) //SpecifyStory
     {         this.ID = id;         this.B iaoti = biaoti ;         this.Author= author;         this.Type = type;




       

     }

var arr = new Array();//declare an array to store title information

 var writer= new ObjStory(11,'Let's go to the sea','Bold Li','Literature and Art');//Declare the object
 arr[0]= writer ;//Add objects to the collection

Another way:

var Array =[];

Array.push (new ObjStory(12,'Let's go to the sea','Li Daudao','Arts') );

Array.push (new  ObjStory(14,'Let's go to the sky','Li Xiaodan','Arts') );



Guess you like

Origin blog.csdn.net/icanlove/article/details/40818559