I am trying to get id of last element of my array.
This is how I am fetching last element of my array
let last = this.Array[this.Array.length-1];
console.log(last);
Here is the console of last element of array-
Object {id: 48, title: "I'm used to this"}
title: "I'm used to this"
id: 48
__proto__: Object
Here is the list on which I have looked already-
How to retrieve the clicked ElementId in angularjs?
How to get the object's id?
how to get the id name in html for any object and many more but I could not.
I just wanted to access id : 48
, can any one help me to do so.
Thanks In Advance.
Just do that:
let last:any = this.Array[this.Array.length-1];
console.log(last.id);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With