Is there any way to replicate Python's array indexing system in JavaScript.
To access the last element in JavaScript, I would need to do this:
last = arr[arr.length - 1]
secondLast = arr[arr.length - 2]
Is there any way I could access the elements using Python's way, eg:
last = arr[-1]
secondLast = arr[-2]
This gets really annoying when you have an array of arrays.
arr = [[1, 2], [3, 4], [5, 6]]
// In JavaScript, to get 6:
lastJS = arr[arr.length - 1][arr[arr.length - 1].length - 1]
# In Python, simple:
lastPy = arr[-1][-1]
Any ideas? All I have seen online only allows arr.last or arr.last() by using Array.prototype.