运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <p>Adding elements with high indexes can create undefined "holes" in an array.</p> <p id="demo"></p> <script> const fruits = ["Banana", "Orange", "Apple"]; fruits[6] = "Lemon"; let fLen = fruits.length; let text = ""; for (i = 0; i < fLen; i++) { text += fruits[i] + "<br>"; } document.getElementById("demo").innerHTML = text; </script> </body> </html>