运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p>The spread operator is often used to extract only what's needed from an array:</p> <p id="demo"></p> <p id="demo2"></p> <p id="demo3"></p> <script> const numbers = [1, 2, 3, 4, 5, 6]; const [one, two, ...rest] = numbers; document.getElementById("demo").innerHTML = one; document.getElementById("demo2").innerHTML = two; document.getElementById("demo3").innerHTML = rest; </script> </body> </html>