jQuery.extend( [deep ], target, object1 [, objectN ] )
<!DOCTYPE html>
<html>
<head>
<title> jQuery extend() method </title>
<script src = "/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
</head>
<body>
<h4> It is an example of using the extend() method. </h4>
<p id = "p1"> <b> First object obj1 is: </b> </p>
<p id = "p2"> <b> Second object obj2 is: </b> </p>
<p id = "p3"> <b> Merged obj2 into obj1: </b> </p>
<script>
var obj1 = {
English: { Price: 150 },
Chemistry: { Price: 250 },
Hindi: { Price: 300, Pages: 275}
};
var obj2 = {
Physics: { Price: 200 },
Hindi: { Price: 250, Pages: 200 }
};
$( "#p1").append( JSON.stringify( obj1 ));
$( "#p2").append( JSON.stringify( obj2 ));
$.extend( obj1, obj2 );
$( "#p3").append( JSON.stringify( obj1 ));
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title> jQuery extend() method </title>
<script src = "/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
</head>
<body>
<h4> It is an example of using the extend() method. </h4>
<p id = "p1"> <b> First object obj1 is: </b> </p>
<p id = "p2"> <b> Second object obj2 is: </b> </p>
<p id = "p3"> <b> Merged obj2 into obj1: </b> </p>
<script>
var obj1 = {
English: { Price: 150 },
Chemistry: { Price: 250 },
Hindi: { Price: 300 }
};
var obj2 = {
Physics: { Price: 200 },
Hindi: { Pages: 200 },
Chemistry: { Pages: 150 }
};
$( "#p1").append( JSON.stringify( obj1 ));
$( "#p2").append( JSON.stringify( obj2 ));
$.extend( true, obj1, obj2 );
$( "#p3").append( JSON.stringify( obj1 ));
</script>
</body>
</html>