phongyewtong phongyewtong - 1 year ago 107
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download