Different template for last item listview


I want to add different item tamplate only for last item in listview, just a button with text add item,
is this possible? i googled it but cant find example in vanilla js


Here is an example



I understand the xml part but, idk how to bind data to this templates, there is short code example but its typescript not a javascript, idk how to write this part in js : Array (Item)


TypeScript is just JavaScript again with static typing, so removing typing is all needed to get it fit inside JS.

function selectItemTemplate(item, index, items) {
    return item.age % 2 === 0 ? "red" : "green";

exports.selectItemTemplate = selectItemTemplate;