方法中的 this
在对象方法中, this 指向调用它所在方法的对象。
fullName 方法所属的对象就是 person。
实例
fullName : function() {
return this.firstName + " " + this.lastName;
}
单独使用 this
单独使用 this,则它指向全局(Global)对象。
在浏览器中,window 就是该全局对象为 [object Window]:
实例
var x = this;
严格模式下,如果单独使用,this 也是指向全局(Global)对象。
实例
"use strict";
var x = this;
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64239.shtml