Blob()
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
.
Syntax
new Blob(array)
new Blob(array, options)
Parameters
array
-
An iterable object such as an
Array
, havingArrayBuffer
s,TypedArray
s,DataView
s,Blob
s, strings, or a mix of any of such elements, that will be put inside theBlob
. Note that strings here are encoded as UTF-8, unlike the usual JavaScript UTF-16 strings. 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 valuenative
.
Return value
A new Blob
object containing the specified data.
Examples
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
Specifications
Specification |
---|
File API # constructorBlob |
Browser compatibility
BCD tables only load in the browser