Created
November 11, 2012 02:59
-
-
Save songxiaofeng1981/4053518 to your computer and use it in GitHub Desktop.
learn:javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//增加对象构造函数,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