Array
Array, is a collection of data items accessible by index at run-time. Types of data items can be various. Index is an integer only. Moscrif does not support associative indexes. You can use a JSON object instead.
There are three ways how to create an Array object in Moscrif:
1. Regular Array
var myCars=new Array(); myCars[0]="Saab"; myCars[1]="Volvo"; myCars[2]="BMW";
2. Condensed array
var myCars=new Array("Saab","Volvo","BMW"); // condensed array
3. Literal array
var myCars=["Saab","Volvo","BMW"]; // literal array
Size of an array is returned by the property length, at any time
var size = myCars.length;
//size equals 3
To manage content of an array, you can use following functions: push, remove and removeByValue.
Example below shows how to add “Mercedes” car and remove “Saab” car from myCars.
myCars.push(“Mercedes”); myCars.removeByValue(“Saab”);
See API documentation of Array here.