代码示例:(标识:eg_js_function_apply)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript 函数</h1>

<p>在此示例中,person 的 fulllName 方法在 person1 上<b>应用</b>:</p>

<p id="demo"></p>

<script>
var person = {
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
}
var person1 = {
  firstName:"Bill",
  lastName: "Gates"
}
var x = person.fullName.apply(person1); 
document.getElementById("demo").innerHTML = x; 
</script>

</body>
</html>
运行结果: