Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Merge Two JavaScript Objects Into One</title> <script> // Sample objects var obj1 = { make: "Audi", model: "Q8" }; var obj2 = { color: "Blue", year: 2021 }; // Merging objects var mergedObj = { ...obj1, ...obj2 }; document.write(JSON.stringify(mergedObj)); </script> </head> <body style="font-family: monospace; white-space: pre;"> <!-- Result will be printed here --> </body> </html>