I have a model with two arrays, bright and normal. Each array includes objects which are representing colors. I want to implement in model a method allowing to set some properties (for example hue) of this colors. So I wrote this:
setHue: function(hue) {
_.each([this.get('brigth'), this.get('normal')], function(colors) {
_.each(colors, function(color) {
color.setHue(hue + this.getHue());
});
});
},
I think it's clear - I try to iterate over every color in both bright
and normal
arrays. And it doesn't update colors inside these arrays. This color inside _.each
seems to have a new value, but it looks it's only a copy of color, not a reference. Do anyone know how to do what I want? I mean with _.each
loop, I don't wanna mess up with for
, length
and indexes.