运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h2>JavaScript const</h2> <p>Declaring a constant array does NOT make the elements unchangeable:</p> <p id="demo"></p> <script> // Create an Array: const cars = ["Saab", "Volvo", "BMW"]; // Change an element: cars[0] = "Toyota"; // Add an element: cars.push("Audi"); // Display the Array: document.getElementById("demo").innerHTML = cars; </script> </body> </html>