Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Print JavaScript Object on a Web Page</title> <script> // Sample object var obj = {name: "John", age: 28, gender: "Male"}; // Converting object to JSON string var str = JSON.stringify(obj); // Printing the string document.write(str); </script> </head> <body style="font-family: monospace;"> <!-- Object will be printed here --> </body> </html>