OneCompiler

[JavaScript] How to get 3rd item from the last in an array?

I want to read 3rd element from the last of an array into a variable, how can we do that in Javascript?

1 Answer

4 years ago by

arr[arr.length - 3] gives you the third element from last present in an array

4 years ago by Meera