Change JS structures efficiently without mutating them