摘要:
每个函数内部有2个特殊对象(this、arguments)、每个函数都包含2个属性(length、prototype)、每个函数都包含2个非继承而来的方法(apply、call) 阅读全文
摘要:
function inheritPrototype(subType, superType){
var prototype = object(superType.prototype); //create object
prototype.constructor = subType; //augment object
subType.prototype = prototype; //assign object
} 阅读全文
摘要:
function Person(name, age, job){
//properties
this.name = name;
this.age = age;
this.job = job;
//methods
if (typeof this.sayName != "function"){
Person.prototype.sayName = function(){
alert(this.name);
};
}
} 阅读全文