How can I always get the last object from the array at the moment I'm using the following function but only takes the first one.
%pre%How can I always get the last object from the array at the moment I'm using the following function but only takes the first one.
%pre%You can search for length using %code% less than 1 that will always return the last item
How can I always get the last object from the array at the moment I'm using the following function but only takes the first one.
var IDs = arrayIds[0].id;
[
{
id: '1',
},
{
id: '2',
},
{
id: '3',
}
]
You can search for length using .length
less than 1 that will always return the last item
let arr = [ '0', '1', '2', '3', '4', '5']
console.log(arr[arr.length -1])