function printHello() {
console.log("Hello")
}
printHello()
let array = [1, 2, 3]
array.push(4) // method of array
console.log(array)
let int = 1
int.push(5) // 不能使用array的method
console.log(int)
關於物件建立的程式碼
let Student1 = {
// key-value pair
name: "小名",
height: 170,
weight: 60,
age: 15,
id: "001",
sing() {
console.log("拉拉拉")
},
run(km) {
console.log("我跑了" + km + "公里")
},
intro() {
console.log("我是" + this.name)
},
}
console.log(Student1.age)
console.log(Student1["age"])
Student1.sing()
Student1.run(10)
Student1.intro()
以上就是今天的教學,感謝大家觀看。