Thanks for the kind words. I'm mixed on negative indices. They are more powerful than a single Array.last property because they let you easily access say, the second to last element [-2]. But I don't find them that much clearer.
That said, JavaScript will likely never get support for negative indices because Array is just an Object, and [-1] is a valid property on either. This would introduce a break change to the language (although it's a pretty bad idea using an Array as a map).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for the kind words. I'm mixed on negative indices. They are more powerful than a single
Array.last
property because they let you easily access say, the second to last element[-2]
. But I don't find them that much clearer.That said, JavaScript will likely never get support for negative indices because Array is just an Object, and
[-1]
is a valid property on either. This would introduce a break change to the language (although it's a pretty bad idea using an Array as a map).