Skip to content

Instantly share code, notes, and snippets.

@alan-w-255
Created July 2, 2018 02:12
Show Gist options
  • Save alan-w-255/098fa768504c4268502c7e36614ff3b5 to your computer and use it in GitHub Desktop.
Save alan-w-255/098fa768504c4268502c7e36614ff3b5 to your computer and use it in GitHub Desktop.
es5 冻结对象
var constantize = (obj) => {
Object.freeze(obj);
Object.keys(obj).forEach( (key, i) => {
if (typeof obj[key] === 'object') {
constantize(obj[key]);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment