<!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>
<script>
var names=['李大','李二','李三','李四','李五']
// 方法一
for(var i=0;i<names.length;i++){
console.log(i,names[i]);
}
// 方法二
for(const key in names){
console.log(key,names[key]);
}
// 方法三
for(const value of names){
console.log(value);
}
// 方法四
names.forEach((value,index,array)=>{
console.log(value,index);
})
</script>
</body>
</html>