Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Overwriting of Property Values When Merging Two JavaScript Objects</title> <script> // Sample objects var obj1 = { name: "John", age: 24 }; var obj2 = { name: "Alice", gender: "female" }; // 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>