If I understand the question correctly, it's as simple as this:
FullScreen.directions.prev = -42;
FullScreen.directions.next = -FullScreen.directions.prev;
It might be better, however, to encapsulate this logic in a function:
FullScreen = {
directions: {
prev: -1,
next: 1,
setPrev: function (value) {
value = +value; // coerce to number
this.prev = value;
this.next = -value;
}
}
}
// then
FullScreen.direction.setPrev(-42);
You could get even fancier using the special get/set
syntax:
FullScreen = {
directions: {
_prev: -1,
_next: 1,
get prev() {
return this._prev;
},
set prev(value) {
value = +value; // coerce to number
this._prev = value;
this._next = -value;
},
get next() {
return this._next;
}
}
}
// then
FullScreen.direction.prev = -42;
// invokes the setter function behind the scenes, so that _next is also set