define(["dojo/_base/declare"], function (declare) {
// module:
// StyleNames
// summary:
// Style element names.
var StyleNames = declare(null,
{
PROP1: "Style1",
PROP2: "Style2"
}
);
StyleNames.dataContexts = [
StyleNames.PROP1,
StyleNames.PROP2,
];
return StyleNames;
});
var styleNames = new StyleNames();
console.log("PROP1 is defined as: ", styleNames.PROP1); // prints "Style1"
console.log("dataContexts is undefined: ", styleNames.dataContexts); // Error: styleNames.dataContexts is undefined
My setup was similar to https://stackoverflow.com/a/11329956/1610451 but looking in the DOM, I can see that it is set to the constructor styleNames.constructor.dataContexts
with undefined values.
Backstory: I'm porting ActionScript code to JavaScript and need to maintain existing interfaces. An example of the ActionScript code that I'm porting is:
public class StyleNames {
public static const PROP1 : String = "Style1";
public static const PROP2 : String = "Style2";
public static const dataContexts : Array = [
PROP1,
PROP2
];
public function StyleNames(){}
}