refactor: use Array.prototype.at()
to get last elements
#17949
Merged
Array.prototype.at()
to get last elements
#17949