fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <div id="log"></div> <script> $(function () { var object1 = { apple: 0, banana: { weight: 52, price: 100 }, cherry: 97 }; var object2 = { banana: { price: 200 }, durian: 100 }; // 将 object2 递归合并到 object1中 $.extend( true, object1, object2 ); // 假设 JSON.stringify - 在 IE版本< 8中无效 $( "#log" ).append( JSON.stringify( object1 ) ); }) </script> </body> </html>
运行结果