jQuery | extend() method Last Updated : 10 May, 2020 Comments Improve Suggest changes Like Article Like Report This extend() Method in jQuery is used to merge the contents of two or more objects together into the first object. Syntax: jQuery.extend( [deep ], target, object1 [, objectN ] ) Parameters: The extend() method accepts four parameter that is mentioned above and described below: deep: This parameter is the merge becomes recursive . target: This parameter is the object to extend. It will receive the new properties. object1: This parameter is the object containing additional properties to merge in. object1: This parameter is an additional objects containing properties to merge in. Return Value: It returns the object after merging. Below examples illustrate the use of extend() method in jQuery: Example 1: In this example, the extend() method merge two objects in one. html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JQuery | extend() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"> </script> </head> <body style="text-align:center;"> <h1 style="color: green"> GeeksForGeeks </h1> <h3>JQuery | extend() method</h3> <p>Merge two objects in One object.</p> <p id = "geeks"> </p> <script> var value1 = { geeks1: 0, geeks2: { topic1: 52, topic2: 100 }, geeks3: 97 }; var value2 = { geeks2: { topic1: 200 }, geeks4: 100 }; // Merge value2 into value1 $.extend( value1, value2 ); // Assuming JSON.stringify - not available in IE<8 $( "#geeks" ).append( JSON.stringify( value1 ) ); </script> </body> </html> Output: Example 2: In this example, the extend() method merge two objects, without modifying any object. html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JQuery | extend() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script> </head> <body style="text-align:center;"> <h1 style="color: green"> GeeksForGeeks </h1> <h3>JQuery | extend() method</h3> <p>Merge two objects, without modifying any object.</p> <p id = "geeks"> </p> <script> var Object_1 = { bool_Val: false, num: 5, name: "shubham" }; var Object_2 = { bool_Val: true, name: "SHUBHAM" }; // Merge Object_1 and Object_2, without modifying Object_1 var Object_3 = $.extend( {}, Object_1, Object_2 ); // Assuming JSON.stringify - not available in IE<8 $( "#geeks" ).append( "<b>Object_1 : </b>" + JSON.stringify( Object_1 ) + "<br>" ); $( "#geeks" ).append( "<b>Object_2 : </b>" + JSON.stringify( Object_2 ) + "<br>" ); $( "#geeks" ).append( "<b>Object_3 : </b>" + JSON.stringify( Object_3 ) + "<br>" ); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article jQuery | extend() method S SHUBHAMSINGH10 Follow Improve Article Tags : Web Technologies JQuery jQuery-Methods Similar Reads jQuery.fn.extend() Method This jQuery.fn.extend() method is used to merge the contents of an object onto the jQuery prototype to provide new jQuery instance methods. Syntax: jQuery.fn.extend( object ) Parameters: This method accepts single parameter as mentioned above and described below: object: This parameter holds the obj 2 min read jQuery append() Method The append() method in jQuery is used to insert some content at the end of the selected elements. Syntax: $(selector).append( content, function(index, html) ) Parameters: This method accepts two parameters as mentioned above and described below: content: It is a required parameter and is used to spe 2 min read jQuery after() Method The after() method is an inbuilt function in jQuery which is used to insert content, specified by the parameter for each selected element in the set of matched elements. Syntax: $(selector).after(A);Parameter: It accepts a parameter "A" which is either a content or function passed to the method. Ret 1 min read jQuery appendTo() Method The appendTo() method is an inbuilt method in jQuery that is used to insert HTML element at the end of the selected element. Syntax: $(content).appendTo(selector)Here the element content specifies the content to be inserted. Parameters: It accepts a parameters "selector" that specifies the elements 1 min read jQuery insertAfter() Method jQuery insertAfter() method is used to insert some HTML content after a specified element. The HTML content will be inserted after each occurrence of the specified element. Syntax:$('content_to_be_inserted').insertAfter(target) Parameters: It takes a parameter "target" which specifies that after th 1 min read Like