Skip to content

Instantly share code, notes, and snippets.

@csainty
Created March 10, 2012 01:59
Show Gist options
  • Save csainty/2009699 to your computer and use it in GitHub Desktop.
Save csainty/2009699 to your computer and use it in GitHub Desktop.
// Person.js
(function () {
var Person = WinJS.Class.define(function (name) {
this.name = name;
}, {
sayHello: function () {
console.log("Hello " + this.name);
}
}, {
createPerson: function (name) {
return new Person(name);
}
});
WinJS.Namespace.define("MyApp", {
Person: Person
});
})();
// Page.js
var bill = new MyApp.Person("bill"); // Created with constructor
bill.sayHello(); // Print Hello bill
var jim = MyApp.Person.createPerson("jim"); // Created with static contructor
jim.sayHello(); // Prints Hello jim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment