JS定义对象数组

var student = new Object();
student.name = "Lanny";
student.age = "25";
student.location = "China";
var json = JSON.stringify(student); 

或

var students = [];
students[students.length] = new Object();
students[students.length].name = "Lanny";
students[students.length].age = "25";
students[students.length].location = "China";
var json = JSON.stringify(students);

你可能感兴趣的:(前端)