我在JS一個初學者,我剛開始今天和W3C例如你可以在javascript中解釋「this」嗎?
var myObject = {
firstName:"John",
lastName: "Doe",
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
myObject.fullName(); // Will return "John Doe"
所以W3C說,「稱這個事情,是對象‘擁有學習功能’的JavaScript代碼。」
有人可以解釋這是一個對象和this
的概念嗎?
感謝
http://javascriptweblog.wordpress.com/2010/08/30/understanding-javascripts-this/ – Nicolas 2014-11-05 17:02:12
[JavaScript「this」keyword]的可能重複(http://stackoverflow.com/questions/3127429/javascript -this-keyword) – 2014-11-05 17:03:38
快速:這代表當前的上下文 – 2014-11-05 17:27:32