I have an array that I created using Array(...)
and Array.prototype.map
, like this:
var array_name = Array(255).map(function(undef, i) {
return i + 1;
});
The values of this array are:
[1, 2, 3, ..., 253, 254, 255]
This is an array that won't get modified, so the first value of this array will always be 1
and the last value of this array will always be 255
.
I already know the index of each value is {value} - 1
, so 200
would be 199
, 199
would be 198
, so on and so forth.
Let's say I want 255
's opposite value, which would be 0
, I could get that using array_name[0]
, but what if I wanted 200
's opposite value, how would I know what the opposite index of 199
is so I could get it's value?