Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Add Key Value Pair to a JavaScript Object Using Dot Notation</title> <script> // Sample object var myCar = { make: "Ferrari", model: "Portofino", year: 2018 }; // Adding a new property myCar.fuel = "Petrol"; document.write(JSON.stringify(myCar)); </script> </head> <body style="font-family: monospace;"> <!-- Object will be printed here --> </body> </html>