javascript的this相关

  1. 函数预编译过程中this指向window(全局)
function test(c){
				var a = 123;
				function b(){}	
				}
				test(1);
AO{
	arguments:[1],
	this : window,
	c    : 1,
	a    : undefined,
	b    : function(){}
}
  1. 全局作用域(GO)中this指向window
  2. call/apply可改变函数运行时的this指向
  3. object.function() function()中的this指向object
var obj = {
		a : function(){}
}
obj.a()
//此时a()中的this指向obj
发布了81 篇原创文章 · 获赞 3 · 访问量 1005

猜你喜欢

转载自blog.csdn.net/qq_43618136/article/details/104090761