Skip to content

Instantly share code, notes, and snippets.

@songxiaofeng1981
Created November 11, 2012 02:59
Show Gist options
  • Save songxiaofeng1981/4053518 to your computer and use it in GitHub Desktop.
Save songxiaofeng1981/4053518 to your computer and use it in GitHub Desktop.
learn:javascript
//增加对象构造函数,call,apply 函数。 匿名函数,内存模型。
var Class = function() {
var klass = function() {
if(typeof klass.constructor == 'function'){
// klass.constructor (arguments[0])
console.log(arguments[0]);
console.log(arguments[1]);
// console.log(arguments[2]);
//研究这个arguments
klass.constructor.apply(klass.prototype,arguments) //todo ,研究这个函数
}
this.show = function() {
// console.log(this.title);
// console.log(this.name);
// console.log(this.name);
// console.log(this.description);
};
};
return klass;
};
var Todo = new Class();
Todo.constructor = function(title,description){
this.title = title;
this.description = description;
}
var todo = new Todo('jobs','test');
todo.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment