The Blob()
constructor returns a new Blob
object. The content of the blob consists of the concatenation of the values given in the parameter array
.
The Blob()
constructor returns a new Blob
object. The content of the blob consists of the concatenation of the values given in the parameter array
.
js
new Blob(array) new Blob(array, options)
array
An iterable object such as an Array
, having ArrayBuffer
s, TypedArray
s, DataView
s, Blob
s, strings, or a mix of any of such elements, that will be put inside the Blob
. Strings should be well-formed Unicode, and lone surrogates are sanitized using the same algorithm as String.prototype.toWellFormed()
.
options
Optional
An object which may specify any of the following properties:
type
Optional
The MIME type of the data that will be stored into the blob. The default value is the empty string, (""
).
endings
Optional Non-standard
How to interpret newline characters (\n
) within the contents, if the data is text. The default value, transparent
, copies newline characters into the blob without changing them. To convert newlines to the host system's native convention, specify the value native
.
A new Blob
object containing the specified data.
js
const array = ['<q id="a"><span id="b">hey!</span></q>']; // an array consisting of a single string const blob = new Blob(array, { type: "text/html" }); // the blob
Specification |
---|
File API # constructorBlob |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
Blob |
20 | 12 | 13Before Firefox 16, the second parameter, when set tonull or undefined , leads to an error instead of being handled as an empty dictionary. |
10IE10 throwsInvalidStateError with a TypedArray argument. Consider using MSBuilder as an alternative. |
12 | 6 | 4.4 | 25 | 14Before Firefox 16, the second parameter, when set tonull or undefined , leads to an error instead of being handled as an empty dictionary. |
12 | 6 | 1.5 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob