How to copy text to clipboard in JavaScript

Strings
By Jad Joubran · 
Last updated Feb 19, 2018
const textToCopy = "npm install webdash";

const el = document.createElement("textarea");
el.textContent = textToCopy;
el.style.cssText = "position: absolute;left:-500%";
document.body.appendChild(el);
el.select();
document.execCommand("copy");
el.remove();