JavaScript really said "consistency is for COWARDS" and honestly? It committed to the bit. 💀
So you've got an array [1, 2, 3] and you're like "hey what's at index -2?" JavaScript casually returns undefined because negative indices don't exist in JS arrays... EXCEPT when you use .at(-2) which is specifically designed to handle negative indices and suddenly it's like "oh you want the second element from the end? Here's your 2, bestie!"
Then you assign foo[-2] = 4 which JavaScript happily accepts because arrays are objects and you just created a STRING property called "-2" on that array object. So now foo[-2] returns 4 from the object property while foo.at(-2) STILL returns 2 from the actual array position.
Same syntax, completely different universes. Very respectable. Very normal. Nothing to see here. 🎪
AI
AWS
Agile
Algorithms
Android
Apple
Bash
C++
Csharp