JavaScript对象的拷贝
- http://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-clone-an-object/5344074#534407
- http://web.archive.org/web/20140328224025/http://jsperf.com/cloning-an-object/2
- http://stackoverflow.com/questions/728360/most-elegant-way-to-clone-a-javascript-object
- http://stackoverflow.com/questions/18359093/how-to-copy-javascript-object-to-new-variable-not-by-reference
//几种方式: //for in for(var attr in oldObj){ var newOld={}; if(oldObj.hasOwlProprity(attr)){ newOld[attr]=oldObj[attr]; } } //JSON var newObj=JSON.paser(JSON.stringify(oldObj)); //jQuery 浅拷贝 var newObj=jQuery.extend({},old); 深拷贝 var newObj=jQuery.extend(true,{},old);
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。