function fn(data) {
let copy
if (typeof (data) === 'function' || typeof (data) === 'object') {
return data
} else if (Array.isArray(data)) {
copy = []
data.forEach(function (item, index) {
copy[index] = fn(item)
})
return copy
} else {
copy = {}
for (let key in data) {
copy[key] = fn(data[key])
}
return copy
}
}