<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type=text/javascript charset=utf-8>
var x = "x";
var y = "yyy";
function F(a){
this.n = 'fsfsf';
this.sc = 4;
var i = new init(this);//F(),this指的是window
i.ii = "ii";
} function init(o){
alert(o);//[object Window]
alert(sc);//4
alert(o.x);//x
alert(o.y);//yyy
this.n = o.sc; //init方法不是对象调用的时候,new的时候this指的是本类的对象,不是window对象
this.name = "namename";
this.o = o;
that = this;
return function(){
alert("333" + this.n);//undefined,this是这个匿名函数的对象
alert("333" + that.n);
this.h = that;
this.k = that.n;
this.a = that.a
}
;
}
alert(1);
var d = F(3);
alert(window.n)//fsfsf
alert(2);
var dd = new d();
alert(window.name)//空
alert(3);
alert(dd.k);//4
alert(dd.h.name);//namename
alert(dd.a.n);//fsfsf
alert(window.k);//undefined
alert(window.h.name);//Cannot read property 'name' of undefined
alert(window.a.n);//Cannot read property 'n' of undefined function F(a){
this.n = 1;
this.sc = 4;
return new init(this);//this是F对象
} function init(a){
alert("111" + a.sc);//4
this.n = a.sc;
return {
k : this.n
}
}
alert(1);
var d = F(3);
alert(d.k); //4 function F(a){
this.n = 1;
this.sc = "scscsc";
}
var d = new F();
alert(window.sc);//undefined
</script>
</head>
<body>
</body>
</html>

最新文章

  1. VS快速生成JSON数据格式对应的实体
  2. java 中与 或 非 异或 和位移运算
  3. 批量删除SharePoint 2010的List中的item
  4. mysql 查看语句的执行效率
  5. POJ1840Eps
  6. 芭比娃娃 Barbara
  7. (C)学生成绩管理系统
  8. pixi.js
  9. [转载] 高性能IO模型浅析
  10. Vue 2.x + Webpack 3.x + Nodejs 多页面项目框架(下篇——多页面VueSSR+热更新Server)
  11. (NO.00001)iOS游戏SpeedBoy Lite成形记(四)
  12. AdminIII连接linux Postgresql过程中的几个小问题
  13. 从字节码看java中 this 的隐式传参
  14. ubuntu双网卡配置,实现内网外网同时访问!
  15. js 实现List
  16. android 中文api
  17. Django之404、500、400错误处理
  18. acm 2057
  19. Liunx mv(转)
  20. OCP 062大量考试新题(2019年)-12

热门文章

  1. [HNOI2006]超级英雄(二分+网络流)
  2. 有关于OpenGL、OpenGL ES、WebGL的小结
  3. ORA-01003: no statement parsed
  4. HIToj--1076--Ordered Fractions(水题)
  5. Material Design控件使用学习 TabLayout+SwipeRefreshlayout
  6. 动态代理(jdk--cglib)
  7. KDD 2011 最佳工业论文中机器学习的实践方法-翻译
  8. 如何更改jar包源码
  9. org.mybatis.spring.mapper.MapperScannerConfigurer$Scanner$1
  10. 目前常见的三种SQL分页方式: