码迷,mamicode.com
首页 > Web开发 > 详细

JS类型和对象的封装代码展示

时间:2015-09-17 11:24:33      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

(function(){...}());

JS CODE:

(function(){
var n = "ime";
function People(name){
this._name = name;

}
People.prototype.say = function(){
alert("peo-hello"+this._name+n);
}
window.People = People;
}());

(function(){
var n = "foo";
function Student(name){
this._name = name;
}
Student.prototype = new People();
var superSsay = Student.prototype.say;
Student.prototype.say = function(){
superSsay.call(this);
alert("stu-hello"+this._name+n);
}
window.Student = Student;
}());
var s = new Student("iwen");
s.say();

JS类型和对象的封装代码展示

标签:

原文地址:http://www.cnblogs.com/htmlphp/p/4815511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!