OneCompiler

[JavaScript] How to get the last element of an array?

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

1 Answer

4 years ago by

arr[arr.length - 1] gives you the last element of an array

4 years ago by Meera