To create a new file with JavaScript, we use the File constructor.
For instance, we write
const f = new File([""], "filename");
to call File with an array with the file contents and a string with the filename respectively.
We can pass in a third argument with some options.
For example, we write
const f = new File([""], "filename.txt", {
type: "text/plain",
lastModified: date,
});
to call File with an object with the MIME type and the lastModified date of the file as the 3rd argument.