<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script>
//將指定的對象放入數組中
//1.創建一個數組
var arr1= new Array();
//2.創建一個空的對象
var student={};
//3.爲對象賦值
student.id="1";
student.name="amy";
console.log("student-->");
console.log(student);
//4.將對象放入數組對象中
arr1.push(student);//push()在數組的末尾添加一個元素;
console.log("arr1:--->");
console.log(arr1);
//創建數組的方式
//1.創建一個數組(常規方式)
var arr2 = new Array();
arr2[0]="Math";
arr2[1]="Chiese";
arr2[2]=student;
console.log("arr2-->")
console.log(arr2);
//2.創建一個數組(簡潔方式)
var arr3 = new Array("1","2",student);
console.log("arr3--->");
console.log(arr3);
//3.創建一個數組(字面量方式)
var arr4 =["1","2",{"id":"1","name":"Mike"}];
console.log("arr4--->")
console.log(arr4);
//訪問數組
console.log("通過指定數組名以及索引訪問某個特定的元素。:")
console.log(arr1[0]);
var sub={
{"id":"1","mc":"amy"},
{"id":"2","mc":"mike"}
}
console.log(sub);
</script>
</html>