Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  122] [ 2]  / answers: 1 / hits: 55582  / 11 Years ago, sun, december 22, 2013, 12:00:00

As typeof returns object..



var MyBlob = new Blob(['test text'], {type : 'text/plain'});
console.log(typeof MyBlob) // object


is it too early to ask for a generic solution for checking whether or not a variable is a blob as it is not yet widely supported? Or how should I go about testing for blob type in browsers which already have it implemented?


More From » types

 Answers
-1

You can test if it is an instanceof Blob like this:




var MyBlob = new Blob(['test text'], {type : 'text/plain'});
document.body.innerHTML = MyBlob instanceof Blob;




This will work for things that inherit from Blob also.


[#73605] Friday, December 20, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grayson

Total Points: 36
Total Questions: 113
Total Answers: 95

Location: Tonga
Member since Fri, Aug 21, 2020
4 Years ago
grayson questions
;