phongyewtong phongyewtong - 10 months ago 29
Javascript Question

What is the proper to write a global const in javascript es6?

What is the right way to write a global const in a script in javascript es6 and use it in some other script?


You just use const at global scope:

const aGlobalConstant = 42;

That creates a global constant. It is not a property of the global object (because const, let, and class don't create properties on the global object), but it is a global constant accessible to all code running within that global environment.