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

<h1>JavaScript Function bind()</h1>

<p>此例将在 3 秒后显示人名:</p>

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

<script>
const person = {
  firstName:"Bill",
  lastName: "Gates",
  display: function() {
    let x = document.getElementById("demo");
    x.innerHTML = this.firstName + " " + this.lastName;
  }
}

let display = person.display.bind(person);
setTimeout(display, 3000);
</script>

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