Skip to content

Instantly share code, notes, and snippets.

@batur
Created June 29, 2023 10:33
Show Gist options
  • Save batur/0c9114628275b5d9a6db7d0895e96733 to your computer and use it in GitHub Desktop.
Save batur/0c9114628275b5d9a6db7d0895e96733 to your computer and use it in GitHub Desktop.
Deep Freezing in JS
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