Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <script src="https://code.jquery.com/jquery-3.5.0.js"></script> </head> <body> <div id="div"></div> <script> let obj1 = { banana: { weight: 25, price: 200 }, cherry: 97 }; let obj2 = { banana: { price: 100 }, durian: 800 }; // Merge obj2 into obj1 $.extend(obj1, obj2); // Assuming JSON.stringify $("#div").append(JSON.stringify(obj1)); </script> </body> </html>