JS declaration variable type:
var x= new Number;var y= new Boolean;var cars= new Array;var person= new Object;
JS array:
var cars=new Array();cars[0]="Audi";cars[1]="BMW";cars[2]="Volvo";
Abbreviation:
var cars=new Array("Audi","BMW","Volvo");
JS object:
Objects are separated by curly brackets. Within the brackets, the attributes of an object are defined in the form of name and value pairs (Name: value.
var person={firstname:"Bill", lastname:"Gates", id:5566};
The object (person) in the preceding example has three attributes: firstname, lastname, and ID.
There are two addressing methods for object attributes:
name=person.lastname;name=person["lastname"];
Mutual conversion between JS and JSON objects
VaR A = {"ID": "1", "name": "lilei", "gender": "boy "};
VaR atostr = JSON. stringify (a); // convert the JSON object to Str
VaR B = '{"ID": "2", "ID": "hanmei", "ID": "girl "}';
VaR btojson = JSON. parse (B); // STR converts a JSON object