Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Define a global read-only, hidden property. |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
globalConst("foo", "bar"); // same as: const foo = "bar"; |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
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" } |
Div | ||
---|---|---|
| ||
AvailabilityThis feature requires:
|
Div | ||
---|---|---|
| ||
See alsoRelated articles:
|