try {
globalConst(sName, vVal);
} catch(e) {
// likely a TypeError if an existing non-configurable property of the same sKey is defined
}
Parameters
Parameter
Type
Mandatory
Description
Util.js version
sName
String
The name of the global constant reference
0.8
vVal
Variant
The value associated with the constant reference
0.8
Return value
If a non-configurable property of the same name is already defined, an error will likely be thrown.
Example
Same as using 'const' declaration in global scope
globalConst("foo", "bar");
// same as:
const foo = "bar";
Create global constant from within a function
function wibble() {
const foo = "bar"; // error; in future might create const within scope of wibble()
globalConst("foo", "bar"); // creates global "foo" constant with value "bar"
}