javaScript07-流程控制-foreach
for、while、dowhile、if语句和Java差不多
JS的foreach语句:
<script>
    let num=[22,33,55,44];
    num.forEach(function (x){
        console.log(x);
    })
    num.forEach(function (x,index,self){
        console.log('元素:'+x+',索引位:'+index+',数组本身:'+self);
    })
</script>

function() 三个参数:
- 第一个参数,ele,当前元素
- 第二个参数,index,当前索引位
- 第三个参数,self,就是数组本身
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号