Javascript has both File
and Blob
for file representation, and both are almost the same thing. Is there a way to check if a variable is holding a File
or a Blob
type of data?
Easiest way:
a = new File([1,2,3], "file.txt");
b = new Blob([1,2,3]);
c = "something else entirely";
a instanceof File
> true
b instanceof File
> false
c instanceof File
> false