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>The JavaScript <i>this</i> Keyword</h1> <p>In this example, <b>this</b> refers to the <b>person</b> object.</p> <p>Because <b>fullName</b> is a method of the person object.</p> <p id="demo"></p> <script> // Create an object: const person = { firstName: "John", lastName: "Doe", id: 5566, fullName : function() { return this.firstName + " " + this.lastName; } }; // Display data from the object: document.getElementById("demo").innerHTML = person.fullName(); </script> </body> </html>