Typescript: Access last element of an array -


is there notation access last element of array in typescript? in ruby can say: array[-1]. there similar? thanks!

you can access array elements it's index. index last element in array length of array-1 ( indexes 0 based).

this should work.

var items: string[] = ["tom", "jeff", "sam"];  alert(items[items.length-1]) 

here working sample.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -