Jquery merge two objects - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:extend

Description

Jquery merge two objects

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from  www  .jav a 2  s  . c om*/
anObj={'propone':'1', 'proptwo':'2'};
anotherObj={'propel':'11', 'proptlv':'12'};
var opts = {};
$.extend(opts, anObj, anotherObj, {
        bar: "baz",
        thing: "foo"
});
console.log(opts);
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials