3 ms·
I don't understand why that would be more error prone than using list[list.length-1]. It's just list[-1].
by robertlagrant 6y ago
I don't understand why that would be more error prone than using list[list.length-1]. It's just list[-1].
- tester34 6y agoimagine if you used list[index] where index would be calculated if you misscalculated something and went on negative, then you'd have big exception/error, but when negative indices are viable, then the code will work fine