How do I select the last array of an undefined long object?

Hello there,

Can the last array of an undefined object be selected? It's undefined because I'm converting the object from an XML string that receives new data from time to time.
this would mean that the 50 has to change at every new stamp.
Since I do not always get the same amount of new data in the xml file, I can not solve this problem with the semantics I know.
payload.data.counterinfo[50].$.value;

Thank you for your suggestions!

well... as payload.data.counterinfo is an array - it will have a length... so payload.data.counterinfo.length will be the total length - the last element will be that minus 1 (as the array starts at 0).

1 Like