<html>
<body>
<h2>JavaScript <b>this</b> 关键词</h2>
<p>在本例中,<b>this</b> 代表 <b>person</b> 对象。</p>
<p>因为 person 对象“拥有” fullName 方法。</p>
<p id="demo"></p>
<script>
// 创建对象:
var person = {
firstName: "Bill",
lastName : "Gates",
id : 678,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
// 显示来自对象的数据:
document.getElementById("demo").innerHTML = person.fullName();
</script>
</body>
</html>