Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Function bind()</h1> <p>In this example, the person object has a display method:</p> <p id="demo"></p> <script> const person = { firstName:"John", lastName: "Doe", display: function() { let x = document.getElementById("demo"); x.innerHTML = this.firstName + " " + this.lastName; } } person.display(); </script> </body> </html>