zoukankan      html  css  js  c++  java
  • JS-Array 对象——copyWithin使用方法

    Javascript 对象有

    1. Array对象
    2. Boolean对象
    3. Date对象
    4. Math对象
    5. Number对象
    6. String对象
    7. RegExp对象

    Array对象用于在变量中存储多个值。

      Array对象属性:

      copyWithin()   从数组的指定位置拷贝元素到数组的另一个指定位置中。

      用法:array.copyWithin(traget,start,end)

      Exp:

      

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta charset="utf-8">
     5 <title>copyWithin()的用法</title>
     6 </head>
     7 <body>
     8 
     9 <p>点击按钮复制数组的前面两个元素到第三和第四个位置上。</p>
    10 
    11 <button onclick="myFunction()">点我</button>
    12 
    13 <p id="demo"></p>
    14 
    15 <p><strong>注意:</strong> IE 11 及更早版本不支持 copyWithin() 方法。</p>
    16     
    17 <script>
    18 var fruits = ["apple","pear","bannar","orange","watermelon","a"];
    19     document.getElementById("demo").innerHTML=fruits;
    20     function myFunction(){
    21         document.getElementById("demo").innerHTML = fruits.copyWithin(3,2,3);
    22     }
    23 </script>
    24 
    25 </body>
    26 </html>


     

  • 相关阅读:
    vue 根据时间时间区间搜索功能
    vue 分页
    ubuntu18 vscode ros 配置
    在ubuntu16上用vscode编译ros历程记录
    word:页眉头部出现一条横线
    word:设置基偶页不同和页眉页脚
    多级标题
    添加论文应用
    添加论文尾注2(交叉引用)
    三线表
  • 原文地址:https://www.cnblogs.com/johnhery/p/9800697.html
Copyright © 2011-2022 走看看