一、认识面向对象
1.面向对象中的概念:
(1)一切事物皆对象
(2)对象具有封装和继承特性
(3)信息隐藏
二、JS面向对象
(function(){
var n = "yelven2"
function Person(name){
var _this = {}
_this._name = name;
_this.sayHello = function(){
alert("PHello"+_this._name+n);
}
return _this;
}
window.Person = Person;
}());
function Teacher(name){
var _this = Person(name);
var superSay = _this.sayHello;
_this.sayHello = function(){
superSay.call(_this);
alert("THello"+_this._name);
}
return _this;
}
var t = Teacher("yeleven");
t.sayHello();原文地址:http://11317783.blog.51cto.com/11307783/1794385