-
Notifications
You must be signed in to change notification settings - Fork 0
/
js0609_index_array.html
69 lines (58 loc) · 1.48 KB
/
js0609_index_array.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
JavaScript_array_classnotes
<script>
let myArr = [1,2,3,4];
let beautiful = ["lancome"," Ysl","Sk2","mac"];
console.log(myArr);
console.log('beautiful',beautiful);
//for
for (let i = 0; i < carsArr.length; i++) {
// console.log(i);
console.log(carsArr[i]);
//Q key ? value ?
// key => i
// value => carsArr[i]
}
// function
function myFun(value, key) {
// js => arrow function 箭頭函式
// function 簡化而來
}
//array裡有 foreach & for of & for in
//foreach
carsArr.forEach((value, key, array) => {
console.log('hello js foreach ');
console.log(key);
console.log(value);
console.log(array);
// e = v
});
carsArr.forEach(element => {
});
//======================================
// 自己練習
// js index array
//let myArr = [1, 3, 5, 7, 9];
// 單一呼叫 array[key]
//console.log(myArr[0]); // 1
//console.log(myArr[1]); // 3
//console.log(myArr[2]); // 5
//console.log(myArr[3]); // 7
//運算子符號
// ==等於
// != 不等於
// if (value != "html") {
// newStudentArr.push(value);
// }
//}
</script>
</body>
</html>