W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数组</h1> <p>keys() 方法返回带有数组键的 Array Iterator 对象。</p> <p id="demo"></p> <script> const fruits = ["Banana", "Orange", "Apple", "Mango"]; const keys = fruits.keys(); let text = ""; for (let x of keys) { text += x + "<br>"; } document.getElementById("demo").innerHTML = text; </script> <p>Internet Explorer 不支持 keys() 方法。</p> </body> </html>