久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript怎么求數(shù)組最大值以及它的下標(biāo)

      方法:1、使用“Math.max(…arr)”語(yǔ)句求出arr數(shù)組的最大值max;2、使用“arr.map(item => item).indexOf(max)”語(yǔ)句根據(jù)最大值求出其下標(biāo)值。

      javascript怎么求數(shù)組最大值以及它的下標(biāo)

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

      javascript求數(shù)組最大值以及它的下標(biāo)

      實(shí)現(xiàn)思路:

      1、使用Math.max()方法求出數(shù)組最大值

      2、根據(jù)最大值獲取其在數(shù)組中的下標(biāo)

      實(shí)現(xiàn)代碼:

      var arr=[2,6,1,5,22,3,66,12,9]; var max=Math.max(...arr); console.log("最大值為:"+max); var index = arr.map(item => item).indexOf(max); console.log("最大值的數(shù)組下標(biāo)為:"+index);

      輸出結(jié)果:

      javascript怎么求數(shù)組最大值以及它的下標(biāo)

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

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