Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Call the Methods of an Object</title> </head> <body> <script> let person = { name: "Peter", age: 28, gender: "Male", displayName: function() { document.write(this.name); } }; person.displayName(); // Prints: Peter document.write("<br>"); person["displayName"](); // Prints: Peter </script> </body> </html>