运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <p>If you use a named index when accessing an array, JavaScript will redefine the array to a standard object, and some array methods and properties will produce undefined or incorrect results.</p> <p id="demo"></p> <script> const person = []; person["firstName"] = "John"; person["lastName"] = "Doe"; person["age"] = 46; document.getElementById("demo").innerHTML = person[0] + " " + person.length; </script> </body> </html>