function freezeObj(obj) {
Object.freeze(obj)
Object.keys(obj).forEach(function (v) {
if (typeof obj[v] === 'object') {
freezeObj(obj[v])
}
})
}
function freezeObj(obj) {
Object.freeze(obj)
Object.keys(obj).forEach(function (v) {
if (typeof obj[v] === 'object') {
freezeObj(obj[v])
}
})
}
本文标题:JS用Object.freeze()递归冻结一个对象
本文链接:https://www.haomeiwen.com/subject/imbswhtx.html
网友评论