码迷,mamicode.com
首页 > 其他好文 > 详细

deepClone

时间:2018-08-23 10:42:35      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:turn   data   两种方法   ring   sig   util   tab   pcl   string   

deepClone: obj => {
var _obj
if (typeof obj === ‘object‘ && obj !== null) {
if (Object.prototype.toString.call(obj) === ‘[object Object]‘) {
_obj = {}
for (var key in obj) {
_obj[key] = utils.deepClone(obj[key])
}
return _obj
} else if (Object.prototype.toString.call(obj) === ‘[object Array]‘) {
_obj = []
for (var _key in obj) {
_obj[_key] = utils.deepClone(obj[_key])
}
return _obj
}
} else {
return obj
}
},
 
数据
JSON.parse(JSON.stringify())
数组
map(_=>_)
filter
find
Array.from()
Array.prototype.forEach
对象
Object.assign({}, this.$route.query, { tabName: data.name })

.除了上面两种方法之外,我们还可以借用JQ的extend方法。

$.extend( [deep ], target, object1 [, objectN ] )

 

 

deepClone

标签:turn   data   两种方法   ring   sig   util   tab   pcl   string   

原文地址:https://www.cnblogs.com/gudun/p/9522141.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!