I am trying to get the last index of a value in an array of objects.
I am unable to make it work; I am expecting the lastIndexOf an element id with value 0.
var sample = [
{
id: 0,
name: 'abbay',
rank: 120
},
{
id: 1,
name: 'sally',
rank: 12
},
{
id: 0,
name: 'abbay',
rank: 129
}
];
var index = this.sample.lastIndexOf(0{id});
Argument of type '0' is not assignable to parameter of type '{id: number; name: string; rank: number;}'.
sample.length - 1this.sample.findIndex(i => i.id == id)