The Selection.focusNode read-only property returns the Node in which the selection ends.
Selection.focusNode
MDN Reference