JavaScript Selection_api Guide
The Selection API represents the user's text selection for custom copy/paste, annotation, and find-in-page features. The guide walks through Getting & Setting Selection. `window.getSelection()` — Selection object. `.toString()` — selected text. `.getRangeAt(0)` — Range object. Set: `const r=document.createRange(); r.selectNode(el); s.removeAllRanges(); s.addRange(r)`. Clear: `s.removeAllRanges()`. The guide is organized into 1 sections that build on each other, each pairing a prose explanation with runnable code. Related guides: Arrays, Strings, Numbers, Math, Date. This is one of 145 JavaScript guides on JS Reference — see the full list on the guides page. Practice what you learn in the JavaScript playground, and look up any unfamiliar term in the JavaScript glossary.