Created
July 2, 2018 02:12
-
-
Save alan-w-255/098fa768504c4268502c7e36614ff3b5 to your computer and use it in GitHub Desktop.
es5 冻结对象
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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