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> <h2>JavaScript Object Methods</h2> <p>Object data can be accessed using property stored as a function.</p> <p id="demo"></p> <script> // Create an object: const person = { firstName: "John", lastName: "Doe", fullName: function() { return this.firstName + " " + this.lastName; } }; // Display data from the object using a method: document.getElementById("demo").innerHTML = person.fullName(); </script> </body> </html>