Created
December 22, 2016 08:25
-
-
Save gracefullight/6235e5c58f204a21073145f5f2137ce0 to your computer and use it in GitHub Desktop.
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
function deepFreeze(obj){ | |
if (!Object.isFrozen(obj)){ | |
Object.freeze(obj); | |
} | |
for (var key in obj) { | |
if ({}.hasOwnProperty.call(obj, key) || !(typeof obj[key] === 'function' || typeof obj[key] === 'object' && !!obj[key])) { | |
continue; | |
} | |
deepFreeze(obj[key]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment