I have an array to be like this var arr = [0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5].
so it contains duplicate values. In here last index value of
'0' is '3',
'1' is '4',
'2' is '5',
'3' is '13',
and so on.
And i counted total duplicate values
var counts = {};
arr.forEach(function(x) { counts[x] = (counts[x] || 0)+1; })
but i want to know last duplicate value index only. please help me.
thanks in advance
countsis an object, there is no "last", as there is no order