This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Define a global read-only, hidden property.

 

Syntax

try {
  globalConst(sName, vVal);
} catch(e) {
  // likely a TypeError if an existing non-configurable property of the same sKey is defined
}

Parameters

ParameterTypeMandatoryDescriptionUtil.js version
sNameString(tick)

The name of the global constant reference

0.8
vValVariant(tick)The value associated with the constant reference0.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"
}

Availability

This feature requires:

  • Util.js v0.8 and above

See also

Related articles:

  • global – reference to the global object/scope

 

  • No labels