1 var dom = function () {};
2 dom.Show = function () {alert('Show Message');};
3 dom.prototype.Display = function () {alert('Property Message');};
4
5 dom.Display();
6 dom.Show();
7 var d = new dom();
8 d.Display();
9 d.Show();
1 var a = {
2 b: function () {
3 this.say = function () {alert('say hello!');};
4 alert("I'm b");
5 }
6 };
1 function counter() {
2 var n = 0;
3 return {
4 count: function() {return n++;},
5 reset: function() {n = 0;}
6 };
7 }
8
9 var x = counter(), y = counter();
10 console.log(x.count());
11 console.log(x.count());
12 console.log(y.count());