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
Post a Comment