Skip to content

Instantly share code, notes, and snippets.

namespace MyApp
{
public static class Functions
{
private static int runningTotal = 0;
private static void adjustTotal(int x, int y)
{
runningTotal += (x + y);
}
// helpers.js
(function() {
var runningTotal = 0;
function adjustTotal(x, y) {
runningTotal += (x + y);
}
WinJS.Namespace.define("MyApp.Functions", {
add: function (x,y) {
// add.js
(function() {
WinJS.Namespace.define("MyApp.Functions", {
add: function (x,y) {
return x + y;
}
});
})();
// subtract.js
// helpers.js
(function() {
WinJS.Namespace.define("MyApp.Functions", {
add: function (x,y) {
return x + y;
}
});
})();
// page.js
// helpers.js
(function() {
function add(x,y) {
return x + y;
}
})();
// page.js
(function() {
console.log(add(1,1)); // throws add is not defined
// helpers.js
(function() {
function add(x,y) {
return x + y;
}
})();
// page.js
console.log(add(1,1)); // throws add is not defined
// helpers.js
function add(x,y) {
return x + y;
}
// page.js
console.log(add(1,1)); // prints 2
(function() {
var x = 1;
})();
console.log(x); // throws "x" is not defined
if (true) {
var x = 1;
}
console.log(x); // Prints 1
(function () {
// some code
})();