37 lines
766 B
JavaScript
37 lines
766 B
JavaScript
let studentNameList = [
|
|
"Phước",
|
|
"Vũ Anh",
|
|
"Ánh Dương"
|
|
]
|
|
|
|
|
|
for(let i = 0; i < studentNameList.length; i++) {
|
|
console.log(studentNameList[i])
|
|
}
|
|
|
|
for (let studentName of studentNameList) {
|
|
console.log(studentName)
|
|
}
|
|
|
|
for (let key in studentNameList) {
|
|
console.log(key)
|
|
}
|
|
|
|
// i -> index
|
|
// studentNameList[i] -> value
|
|
// studentNameList.length -> thuộc tính length
|
|
|
|
// studentNameList.push() -> phương thức (method ~ function)
|
|
|
|
// studentNameList.push("Nam")
|
|
// studentNameList.push("Hồng", "Yến", "Tâm")
|
|
|
|
console.log("studentNameList", studentNameList)
|
|
|
|
studentNameList.splice(1, 1)
|
|
|
|
console.log("studentNameList", studentNameList)
|
|
|
|
studentNameList[0] = "Phước Đẹp Trai"
|
|
|
|
console.log("studentNameList", studentNameList) |