Define a Global variable in WinJS
– Can be declared in any exitsing global JS file in the project, to get the access through out the project.
– default.JS file can also be a used to declare global variables.
Syntax
WinJS.Namespace.define("<Namespace Name>",{<variable name>: <valu>,});
Example
WinJS.Namespace.define("MyNameSpace", { MyGlobalVariable: 1 , });
– The datatype of the variable gets automatically decided basing upon the value assigned.
Usage of the variable
– Can be accessed from any file of the project
Syntax
<NameSpaceName>.<VariableName>;
Example
MyNameSpace.MyGlobalVariable=10; var myVarValue=MyNameSpace.MyGlobalVariable;