javascript - Change value of same field on multiple objects - JS -
i have object on scope, the_data
, has multiple objects inside it.
one object, important_entries
has list of objects inside it.
the objects inside important_entries
have specific field want change - field_i_want_to_change
. name of each of these objects it's id.
what want iterate on important_entries
object , each object in it, change value of each field_i_want_to_change
field.
could possibly give me pointers how best accomplish this? have access underscore library, if can of use.
here rough blueprint of the_data
object, apologise syntax errors.
the_data : { some_data : {}, some_data : {}, important_entries: { xxxccc : { field_i_want_to_change: 'some data' }, cccfff : { field_i_want_to_change: 'some data' }, tttyyy : { field_i_want_to_change: 'some data' }, }, some_data : {}, some_data : {} }
why don't loop through javascript object , change field?
p = the_data['important_entries']; (var key in p) { if (p.hasownproperty(key)) { p[key].field_i_want_to_change = 'some data'; } }
Comments
Post a Comment