标签:highlight 索引 ++ body doctype 循环 char for i++
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> //js中有两种for循环 //第一种循环的是下标和key <script> var a=[11,22,33,44] for (var item in a){ //循环的是a的索引 console.log(a[item]) } //循环字典操作 var b={"k1":"v1","k2":"v2",} for (var item in b){ console.log(b[item]) } </script> //for循环产生下标 不支持字典操作 <script> var a=[11,22,33,44] for (var i =0;i<a.length;i++){ console.log(a[i]) } </script> </body> </html>
标签:highlight 索引 ++ body doctype 循环 char for i++
原文地址:https://www.cnblogs.com/randomlee/p/9720940.html