javascript写类方式之六
这篇开始会分析流行的js库之写类方式。各种库的写类方式虽然千奇百怪,但仍然逃离不了本质---用构造函数和原型来组装类。
?
6、Prototype.js的写类方式
?
Person.prototype = {constructor : Person,//注意这里initialize : function(name) {this.name = name;},getName : function() {return this.name;},setName : function(name) {this.name = name;}}?
?
好了,这时候p.constructor == Person就是true了。
?
?
?
?
1 楼 lixinlixin2008 2009-06-29 感觉prototype这种对象创建挺怪异的...