Actually no, window.getSelection() returns no text and object
Selection. And if you are trying to work with text, it automatically works its toString() method and you will get text only "Hello World".
If you look at the documentation, then there are
Selection.anchorNode // Returns the Node in which the selection begins.
and also
Selection.focusNode // Returns the Node in which the selection ends.
Everything is so complicated because the selection may start in the middle of one tag, and end in the middle of another, something like this:
