jquery - Automatically update JavaScript object property when another object's property is set -
i have array of objects, each containing property named title
.
title
property can hold 1 of 2 possible string values - "main"
or "local"
. single element in array can have "main"
title
value @ given time, , rest of elements should have title
property set "local"
.
for instance, take following array:
var locations = [ { title:"main", place:"uk" }, { title:"local", place:"usa" }, { title:"local", place:"russia" } ]
when setting place:"usa"
object's title
property "main
", want place:"uk"
object's title
property automatically set "local"
.
how achieve javascript?
one way set title
values local
, before setting desired object main
. way remember index set main
, revert local when main
changed.
Comments
Post a Comment