---
title: "Merge the two object using jQuery"  
description: "Merge the two object using jQuery"  
author: "Ethan Karla"  
published: 2021-07-28  
updated: 2023-11-28  
canonical: https://www.mindstick.com/forum/156636/merge-the-two-object-using-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Merge the two object using jQuery

How to [merge two](https://www.mindstick.com/forum/23218/merge-two-python-dictionaries-in-a-single-expression) object using jQuery?\
\

## Replies

### Reply by Aryan Kumar

Certainly! To [merge](https://www.mindstick.com/startup/15/how-growthpal-helps-companies-make-the-right) two objects using jQuery, you can use the **$.extend()** method. Here's an example:

```plaintext
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Merge Objects with jQuery</title>
  <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
</head>
<body>

  <script>
    // Two sample objects to merge
    var obj1 = { name: "John", age: 25 };
    var obj2 = { occupation: "Developer", city: "New York" };

    // Using jQuery's $.extend() to merge the objects
    var mergedObject = $.extend({}, obj1, obj2);

    // Displaying the merged object in the console
    console.log(mergedObject);
  </script>

</body>
</html>
```

In this example, **$.extend({}, obj1, obj2)** is used to merge **obj1** and **obj2**. The empty object **{}** at the beginning is the target object where the properties will be merged. The merged object is then displayed in the console.

Feel free to customize the objects and their properties based on your specific use case.


---

Original Source: https://www.mindstick.com/forum/156636/merge-the-two-object-using-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
