标签:bar for img too 数组 class for循环 bsp length
用for循环取数组的值
第一种
<script>
// 用for循环取数组的值
function f1(){
let a = [‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘];
for (let item in a){
// console.log(a[item]);
let s = a[item] + "<br/>";
document.write(s);
}
}
setInterval(‘f1();‘, 500);
<script/>
第二种
<script>
function f1(){
let a = [‘A‘, ‘B‘, ‘C‘, ‘D‘, ‘E‘];
for (let item=0; item<a.length; item++){
// console.log(a[item]);
let s = a[item] + "<br/>";
document.write(s);
}
}
setInterval(‘f1();‘, 500);
</script>
用for循环取对象的值
<script>
//用for循环取对象的值
function f1(){
let a = {‘k1‘:‘A‘, ‘k2‘:‘B‘, ‘k3‘:‘C‘, ‘k4‘:‘D‘,‘k5‘:‘E‘};
for (let item in a){
// console.log(a[item]);
let s = a[item] + "<br/>";
document.write(s);
}
}
setInterval(‘f1();‘, 500)
</script>
标签:bar for img too 数组 class for循环 bsp length
原文地址:https://www.cnblogs.com/wjybk/p/11873438.html