app/test/prototype.js
raw| 1 | /** @constructor */ |
| 2 | function Article() { |
| 3 | } |
| 4 | |
| 5 | Article.prototype.init = function(title) { |
| 6 | /** the instance title */ |
| 7 | this.title = title; |
| 8 | |
| 9 | /** the static counter */ |
| 10 | Article.counter = 1; |
| 11 | } |
| 12 | |
| 13 | a = new Article(); |
| 14 | a.Init("my title"); |
| 15 | |
| 16 | print(a.title); |
| 17 | print(Article.counter); |