全局对象window
- 在标准里面全局对象叫glabol(浏览器windos)
-
属性举例global.parseInt
1
-
每次页面生成时,会声明一个glabol
2
-
window的属性
3
- window.可以不加
全局函数
-
每个浏览器实现不同的函数
4
5
6
7
8
9
-
临时转换,tamp用了就没了
10
- n.xxx的临时变量产生被赋值2,用完后抹杀了。
各种API




-
包前不包后
15
16
17
18
19
- 所有声明对象不相等
用的属性藏在哪里
问题:公用属性



toString是哪来的----原型链


-
原型=共有属性
25z
26
27
-
当声明对象时,js引擎除了在栈里弄出哈希外,还__p指向共有属性
28
- String.prototype是String的公用属性
的引用(防止跑的) - s.proto是String的公用属性的引用(用的)
形式上区别


1.对象属性
2.函数属性


- 画图的时候认为 Object.proto === Object.prototype ,
实际上应该是 Object.proto === Function.prototype,因为 Function 是 Object 的构造函数。 - 画图时认为 Object.prototype.proto 指向自己,
实际上应该是指向 null
注意大小写,number 和 Number 是不同的
重要公式
- var 对象 = new 函数()
对象.proto === 对象的构造函数.prototype
// 推论
- var number = new Number()
number.proto = Number.prototype
- var object = new Object()
object.proto = Object.prototype
- var function = new Function()
function.proto = Function.prototype
// 另外,所有函数都是由 Function 构造出来的,所以
- Number.proto = Function.prototype // 因为 Number 是函数,是 Function 的实例
- Object.proto = Function.prototype // 因为 Object 是函数,是 Function 的实例
- Function.proto == Function.prototye // 因为 Function 是函数,是 Function 的实例!
网友评论