I discovered the copy()
function in Chrome by accident. When I tested it out, it copied an inputted string to my clipboard.
I've seen more complicated ways to copy a string to clipboard, and many of which are barely full-browser compatible. However, this copy()
function is by far the simplest solution because it appears to be native code. I know this because typing this function without the parentheses returns this:
ƒ copy(value) { [Command Line API] }
This seems like a super useful function for the project I'm working on at the moment, but I don't want to implement it right away. Before I utilize this, I want to know its compatibility with other browsers. I have tried googling this command but yielded no results to my amazement. This also has me wondering, is this a new function or API or whatever? Why am I only learning about this now? Why can I find no information about this incredibly useful function?
Also, I think it is important to note that I am using chrome, presumably the latest version, with no extensions that, to my knowledge, add function like these to the console.