自訂物件導向變數object
(1).物件object變數,建立方法:
方法1:(最常使用)
stu = {name:"john", chinese:95, english:75, math:70};
(2).物件object變數的陣列
方法1:(最常使用)
stu = [{name:"john", chinese:95, english:75, math:70},{name:"tom", chinese:75, english:85, math:60},{name:"peter", chinese:95, english:100, math:65}];
方法2:
var stu = new Array(); //一維陣列 物件
stu[0] = {name:"john", chinese:95, english:65};
stu[1] = {name:"tom", chinese:85, english:65};
方法3:
var stu = new Array(); //一維陣列 物件
var stu[0] = new Object();
stu[0].name = "john";
stu[0].chinese = 95;
stu[0].english = 75;
stu[0].math = 70;
var stu[1] = new Object();
stu[1].name = "tom";
stu[1].chinese = 85;
stu[1].english = 85;
stu[1].math = 90;