Careful, the previous solution assumes the geometry is a single-part polyline, which seems to be ok for this use case, but might not work in all situations, like when the geometry is retrieved from an external source like a Map or Feature Service.
var lastPartIdx = polyline.paths.length-1;
var lastPntIdx = polyline.paths[lastPartIdx].length - 1;
var lastPnt = polyline.getPoint(lastPartIdx , lastPntIdx);