Object.clone(obj) -->Object
原api的用途:
Clones the passed object using shallow copy(copies all the original's properties the result).
克隆被传过来的参数对象的浅复制(给返回的对象复制所有源的属性)。
Do note that this is shallow copy, not deep copy.
注意一下这个是浅复制,不是深度克隆
用例:
var obj = {name:'zhangyaochun',job:'fe'}; var newObj = Object.clone(obj); newObj.name = 'newName'; console.log(newObj.name); //newName console.log(obj.name); //zhangyaochun
源码展示:
关于Object.extend请看http://zhangyaochun.iteye.com/blog/1425306
clone:function(obj){ return Object.extend({ },obj); }