Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
37
rated 0 times [  40] [ 3]  / answers: 1 / hits: 43216  / 12 Years ago, sun, august 5, 2012, 12:00:00

I'm reading http://www.html5rocks.com/en/tutorials/file/xhr2/ and trying to figure out the difference between an ArrayBuffer and a Blob.


Aren't both containers comprised of bits? Hence, couldn't both containers be viewed in many ways (as 32-bit chunks, 16-bit chunks, etc.)?


More From » html

 Answers
105

It's explained on the page.



ArrayBuffer




An ArrayBuffer is a generic fixed-length container for binary data. They are super handy if you need a generalized buffer of raw data, but the real power behind these guys is that you can create views of the underlying data using JavaScript typed arrays. In fact, multiple views can be created from a single ArrayBuffer source. For example, you could create an 8-bit integer array that shares the same ArrayBuffer as an existing 32-bit integer array from the same data. The underlying data remains the same, we just create different representations of it.




BLOB




If you want to work directly with a Blob and/or don't need to manipulate any of the file's bytes, use xhr.responseType='blob':



[#83835] Saturday, August 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
juancarlos

Total Points: 580
Total Questions: 105
Total Answers: 103

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
;