I made an object called Fullscreen, and within the object another object called directions. so my code looks like this:
FullScreen = {
directions: {
prev: -1,
next: 1
}
}
but i want to be able to set FullScreen.directions.prev from outside the object, and change FullScreen.directions.next to the negative value of the prev. any ideas how to do this?
If I understand the question correctly, it’s as simple as this:
It might be better, however, to encapsulate this logic in a function:
You could get even fancier using the special
get/setsyntax: