Copy string to clipboard, without using a DOM element?

I have this code that works:

let textarea = document.createElement('textarea');
textarea.setAttribute('type', 'hidden');
textarea.textContent = 'the string you want to copy';

as you can see - I have the string to copy in hand. But I have to create a temporary hidden DOM element to score the string before copying to the clipboard.

My question is, is there some API to copy to clipboard without needing the DOM at all? something like this:

document.execCommand('copy', 'the string data to put in clipboard');

seems weird that the DOM is necessary to do this. Also, as a side note, this clipboard API is super strange, anyone else agree?