There are four ways to define an array
Use the constructor:
var a = new Array();
var b = new Array(10);
var c = new Array("first", "second", "third");
Or array direct quantity:
var d = ["first", "second", "third"];
Extensions:
function ObjStory(id,biaoti,author,type) //Declare object { this.ID = id; this.Biaoti=biaoti; this.Author= author; this.Type = type; }var arr = new Array();//Declare array to store title information var writer= new ObjStory(11,'Everyone go see the sea','Li Dabang','Literary Class');//Declare object arr[0]=writer;//Add objects to the collectionAnother way:
var Array=[];
Array.push(new ObjStory(12,'Everyone goes to see the sea','Li Dabang','Literary and Art Category'));
Array.push(new ObjStory(14,'Everyone goes to see the sky','Li Xiaodan','Literary and Arts'));
The above simple example of js declaring arrays and adding object variables to arrays is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.