Can global constants be declared in JavaScript?

前端 未结 8 837
耶瑟儿~
耶瑟儿~ 2020-12-16 09:33

If so, what is the syntax for such a declaration?

8条回答
  •  独厮守ぢ
    2020-12-16 09:52

    As "Pointy" so carefully notes, ECMAscript has no such feature. However, JavaScript does:

    const a = 7;
    document.writeln("a is " + a + ".");
    

    Of course, if you're writing code to put on the web to run in web browsers, this might not help you much. :-)

提交回复
热议问题