Created
June 29, 2023 10:33
-
-
Save batur/0c9114628275b5d9a6db7d0895e96733 to your computer and use it in GitHub Desktop.
Deep Freezing in JS
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
const deepFreeze = obj => { | |
Object.keys(obj).forEach(prop => { | |
if (typeof obj[prop] === 'object') deepFreeze(obj[prop]); | |
}); | |
return Object.freeze(obj); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment