<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
</head>
<body>
</body>
</html>
<script>
// js中的循环有两种:for循环、while循环
// 1. for循环
// 1)python中for循环: for-in循环
/*
for(变量 in 序列){
循环体
}
注意:不管序列是什么类型,变量取的都是下标或者属性名
*/
str1 = 'abc'
for(index in str1){
console.log(index, str1[index])
}
array1 = [106,false,'abc',[1,2,3]]
for(index in array1){
console.log(index,array1[index])
}
// 2. while循环
// 1)python中while循环
/*
while(条件语句){
循环体
}
*/
</script>
网友评论