久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript的Array如何輸出

      javascript的Array輸出方式有:1、使用“for in”方法循環(huán)輸出數(shù)組;2、使用for循環(huán)輸出數(shù)組;3、使用forEach循環(huán)輸出數(shù)組;4、使用for-of循環(huán)輸出數(shù)組。

      javascript的Array如何輸出

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      JavaScript中可以通過循環(huán)遍歷數(shù)組,在循環(huán)中使用document.writeln()或者console.log()方法輸出數(shù)組。

      javascript中輸出數(shù)組示例:

      1、使用for in方法循環(huán)輸出數(shù)組:

      <script language="javascript" type="text/javascript"> var str = "how are you today"; var arr = str.split(" "); for(var key in arr){  document.writeln(arr[key]); } </script>

      2、使用for循環(huán)輸出數(shù)組:

      <script language="javascript" type="text/javascript"> var str = "how are you today"; var arr = str.split(" "); for(var i=0;i<arr.length;i++){  document.writeln(arr[i]); } </script>

      3、使用forEach循環(huán)輸出數(shù)組:

      var arr = [1, 2, 3, 4]; arr.forEach(function(val, index) {     console.log(val, index); });

      4、使用for-of循環(huán)輸出數(shù)組:

      for-of是ES6中新增的一個遍歷數(shù)組或者類數(shù)組的方法。它的出現(xiàn)主要是為了解決ES5中3種遍歷方式的缺陷:

      forEach 不能break 或者return

      let arr=[3,7,9];      for (let key of arr){              console.log(key);     }

      JavaScript數(shù)組:

      數(shù)組對象用來在單獨(dú)的變量名中存儲一系列的值。

      【推薦學(xué)習(xí):javascript高級教程】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號