首页 > 编程语言 > 详细

JavaScript面向对象详解

时间:2016-06-29 23:49:54      阅读:394      评论:0      收藏:0      [点我收藏+]

一、认识面向对象

    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();


JavaScript面向对象详解

原文:http://11317783.blog.51cto.com/11307783/1794385

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!