In JavaScript, you can copy text to the clipboard using the Clipboard API or by working with input/textarea elements. Below are two common approaches.