W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数组</h1> <p>将前两个数组元素复制到第三和第四个位置:</p> <p id="demo"></p> <script> const fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi", "Papaya"]; document.getElementById("demo").innerHTML = fruits.copyWithin(2,0,2); </script> <p>Internet Explorer 不支持 copyWithin() 方法。</p> </body> </html>