I have to convert a python code to javascript. Now in this code we are dealing with lists like so :
selected_element = current_list[index_col]
The index_col
is an index that come from a database. I cannot really manipulate it because it has to keep the same value for another part in the code.
Some of thoses indexes are negatives (-3, -5, and so on)
So i need a simple solution to pretty keep the same syntax current_array[index_col]
(I replace list
by array
here in order to respect the JS syntax names), that would allow me to deal with negative values.
I cannot use external libraries, all must be implemented in vanilla javascript (no lodash)
So far I found :
Accessing an element of an array through negative indexes
But is does not really help me to keep the same syntax. I must keep this syntax current_array[index_col]
.