As a problem, a simple application of a single object has been completed, with the hope of defining an array that can contain multiple student.
Copy Code code as follows:
var student = new Object ();
Student.name = "Lanny";
Student.age = "25";
Student.location = "the";
var json = json.stringify (student);
Method One:
Copy Code code as follows:
var students = [];
Students[students.length] = new Object ();
Students[students.length].name = "Lanny";
Students[students.length].age = "25";
Students[students.length].location = "the";
var json = json.stringify (students);
Method Two:
Copy Code code as follows:
var student = new Object ();
Student.name = "Lanny";
Student.age = "25";
Student.location = "the";
Students = (Students | | []). push (student);
var json = json.stringify (students);
See more JavaScript syntax, you can focus on: JavaScript reference tutorial, JavaScript Code style guide, and also hope that many people support the cloud-Habitat community.