I\'m having array of objects where object looks like this (values change):
{
stats: {
hp: 2,
mp: 0,
defence: 4,
agili
To be clear, the issue is not purely that the array is frozen. Frozen arrays can be iterated over. As noted in ReactJS - sorting - TypeError: 0 is read only, the issue is that Array.sort
sorts the array in-place, meaning it attempts to mutate the array. That's why you need to pass it a mutable copy of the array.