W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>使用 const 声明变量</h1> <p id="demo"></p> <script> var x = 10; // Here x is 10 { const x = 2; // Here x is 2 } // Here x is 10 document.getElementById("demo").innerHTML = x; </script> </body> </html>