Skip to content

Instantly share code, notes, and snippets.

@songxiaofeng1981
Created November 11, 2012 02:58
Show Gist options
  • Save songxiaofeng1981/4053516 to your computer and use it in GitHub Desktop.
Save songxiaofeng1981/4053516 to your computer and use it in GitHub Desktop.
learn javascript
var Class = function () {
var klass = function () {
this.initialize.apply(this,arguments) //this中没有init,找原型
};
klass.fn = klass.prototype;//todo 污染
return klass;
};
var Model = new Class(); //定义类
Model.fn.initialize = function () {
this.save = function () {};
};//定义构造函数
var todo = new Model();
console.log(typeof todo.save);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment