JS之数组代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS之数组代码</title>
</head>
<body>
<script>
/******************* JS之数组代码 **********************/
//定义数组
var arr = ['刘备', '关羽', '张飞'];
//输出数组
console.log(arr); //结果:['刘备', '关羽', '张飞']
//遍历输出数组
for(var i=0; i<arr.length; i++){
console.log(arr[i]); //结果:刘备 关羽 张飞
}
</script>
</body>
</html>