<!DOCTYPE html> <html> <body> <h1>JavaScript Function bind()</h1> <p>在这个例子中,person 对象有一个 display 方法:</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; } } person.display(); </script> </body> </html>