面向对象详解1

OO1.html

 <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script src="js/app1.js"></script>
</body>
</html>

js/app1.js

 /*function People(){

 }
People.prototype.say=function(){
alert("hello");
}
function Student(){ }
Student.prototype=new People();
var superSsay=Student.prototype.say;
Student.prototype.say=function(){
superSsay.call(this);
alert("stu-hello");
}
var s=new Student();
s.say();*/ /*function People(name){
this._name=name;
}
People.prototype.say=function(){
alert("peo-hello"+this._name);
}
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);
}
var s=new Student("iwen");
s.say();*/ (function(){
var n="ime";
function People(name){
this._name=name;
}
People.prototype.say=function(){
alert("peo-hello"+this._name);
}
window.People=People;
}()); (function(){
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);
}
window.Student=Student;
}()); var s=new Student("iwen");
s.say();

面向对象详解2

OO2.html

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="js/app2.js"></script>
</body>
</html>

js/app2.js

 /*function Person(){
var _this={};
_this.sayHello=function(){
alert("P-hello");
}
return _this;
}
function Teacher(){
var _this=Person();
var surperSay=_this.sayHello;
_this.sayHello=function(){
surperSay.call(_this);
alert("T-hello");
}
return _this; }
var t=Teacher();
t.sayHello();
*/ /*function Person(name){
var _this={};
_this._name=name;
_this.sayHello=function(){
alert("P-hello"+_this._name);
}
return _this;
}
function Teacher(name){
var _this=Person(name);
var surperSay=_this.sayHello;
_this.sayHello=function(){
surperSay.call(_this);
alert("T-hello"+_this._name);
}
return _this; }
var t=Teacher("iwen");
t.sayHello();*/ (function(){
var n="ime";
function Person(name){
var _this={};
_this._name=name;
_this.sayHello=function(){
alert("P-hello"+_this._name+n);
}
return _this;
}
window.Person=Person;
}());
function Teacher(name){
var _this=Person(name);
var surperSay=_this.sayHello;
_this.sayHello=function(){
surperSay.call(_this);
alert("T-hello"+_this._name);
}
return _this; }
var t=Teacher("iwen");
t.sayHello();

JS 面向对象详解的更多相关文章

  1. Java面向对象详解

    Java面向对象详解 前言:接触项目开发也有很长一段时间了,最近开始萌发出想回过头来写写以前学 过的基础知识的想法.一是原来刚开始学习接触编程,一个人跌跌撞撞摸索着往前走,初学的时候很多东西理解的也懵 ...

  2. js对象详解(JavaScript对象深度剖析,深度理解js对象)

    js对象详解(JavaScript对象深度剖析,深度理解js对象) 这算是酝酿很久的一篇文章了. JavaScript作为一个基于对象(没有类的概念)的语言,从入门到精通到放弃一直会被对象这个问题围绕 ...

  3. java之面向对象详解

    #############java面向对象详解#############1.面向对象基本概念2.类与对象3.类和对象的定义格式4.对象与内存分析5.封装性6.构造方法7.this关键字8.值传递与引用 ...

  4. php开发面试题---php面向对象详解(对象的主要三个特性)

    php开发面试题---php面向对象详解(对象的主要三个特性) 一.总结 一句话总结: 对象的行为:可以对 对象施加那些操作,开灯,关灯就是行为. 对象的形态:当施加那些方法是对象如何响应,颜色,尺寸 ...

  5. C#基础-面向对象详解

    面向对象详解 一.什么是面向对象 1>面向对象是一种程序设计思想 2>面向过程和面向对象是什么? 例如要把大象放冰箱怎么做? 面向过程:打开冰箱门->把大象扔进去->关上冰箱门 ...

  6. Node.js npm 详解

    一.npm简介 安装npm请阅读我之前的文章Hello Node中npm安装那一部分,不过只介绍了linux平台,如果是其它平台,有前辈写了更加详细的介绍. npm的全称:Node Package M ...

  7. Vue.js项目详解

    还是以Blog项目来讲解,最近我本人利用闲暇时间,以博客作为参考学习一些新的技术并尝试之前没有尝试过的思路来玩玩. 技术看似枯燥,但是带有一个目的来学,你会发现还是蛮有趣的. 主要实践的就是前后端分离 ...

  8. 开胃小菜——impress.js代码详解

    README 友情提醒,下面有大量代码,由于网页上代码显示都是同一个颜色,所以推荐大家复制到自己的代码编辑器中看. 今天闲来无事,研究了一番impress.js的源码.由于之前研究过jQuery,看i ...

  9. jquery图片切换插件jquery.cycle.js参数详解

    转自:国人的力量 blog.163.com/xz551@126/blog/static/821257972012101541835491/ 自从使用了jquery.cycle.js,我觉得再也不用自己 ...

随机推荐

  1. 符合RESTful规范的API

    统一使用的utils,serializers: class BaseResponse: def __init__(self): self.code = 1000 self.data = None se ...

  2. Apache Kylin本地启动

    首先:kylin是一种Online Analytics Platform.    kylin 在Apache的首页是http://kylin.apache.org/cn/.    kylin git代 ...

  3. 使用MVC实现登录功能

    首先,从底层开始即Models: (1)通用数据访问类(封装数据访问类方法):SqlHelper类 使用命名空间:using System.Data; using System.Data.SqlCli ...

  4. selenium webdriver——JS操作日历控件

    一般的日期控件都是input标签下弹出来的,如果使用webdriver 去设置日期, 1. 定位到该input 2. 使用sendKeys 方法 比如 但是,有的日期控件是readonly的 比如12 ...

  5. mybatis 需要注意的点 MyBatis 插入空值时,需要指定JdbcType (201

    转自:https://blog.csdn.net/snakemoving/article/details/76052875 前天遇到一个问题 异常显示如下: 引用 Exception in threa ...

  6. 【python】 time模块和datetime模块详解 【转】

    一.time模块 time模块中时间表现的格式主要有三种: a.timestamp时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算的偏移量 b.struct_time时间元组,共 ...

  7. fft 远程服务器返回错误 550返回码

    "远程服务器返回错误:(550) 文件不可用(例如,未找到文件,无法访问文件)"时,可能是如下原因: 1.URL路径不对,看看有没有多加空格,或者大小写问题 2.权限是否足 3.需 ...

  8. tomcat8 安全加固

    本文基于tomcat8.0.24 1.删除文档和示例程序 [操作目的]删除示例文档 [加固方法]删除webapps/docs.examples.manager.ROOT.host-manager [是 ...

  9. 生产者消费者模式做一个golang的定时器

    在主程序启动的时候开一个goroutine作为消费者,用管道连接生产者和消费者,消费者处于无限循环,从管道中获取channel传过来定时event 注意:channel在消费者创建的时候就连通生产者和 ...

  10. Python_01-入门基础

    以后我会发表一系列python脚本的学习资料,python版本为2.x. 目录: 1 Python入门基础 1.1 学习资源 1.2 所有语言的入门程序---Hello World!  1.3 帮助函 ...