So, I have a Javascript module that looks like this:
const data = [
{
id: 'do not modify',
name: 'do not modify'
},
{
id: 'do not modify 2',
name: 'do not modify 2'
}
];
export default data;
Is there a clean way I can recursively freeze all objects in an array without calling it explicitly Object.freeze()for each object? I understand that I can just skip the array and freeze each one before exporting, but I was curious to find out if there was a more elegant solution.
source
share