Blob: immutable byte sequences
Quick answer
A Blob represents immutable bytes and optional media-type metadata. It is useful for constructing downloads or passing binary data between host APIs.
How it works
new Blob(parts,{type}) combines strings and binary parts. Strings are encoded as UTF-8. size counts bytes; type is metadata, not proof of format. text() decodes UTF-8 and arrayBuffer() resolves to a copy of the bytes. slice(start,end,type) selects a byte range, not characters.
Local examples
Run in a fresh browser document. Uses synthetic local data; actual ByteMind editor support is unverified.
(async () => {const b=new Blob(["é"],{type:"text/plain"});console.log(b.size,b.type);})()Expected console output:
2 text/plainThe UTF-8 representation of é occupies two bytes.
Run in a fresh browser document. Uses synthetic local data; actual ByteMind editor support is unverified.
(async () => {const b=new Blob(["abcd"]);console.log(await b.slice(1,3).text());})()Expected console output:
bcThe interval contains byte positions 1 and 2.
Common mistakes
Do not assume one Unicode character occupies one byte or that setting a MIME type converts the contents.
Practice
Construct a Blob containing a Persian word, inspect size and compare it with the string length.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Blob: immutable byte sequences — Knowledge Check
Apply the concept and reason about local example output.
What does Blob.size measure?
Does setting Blob.type convert its contents to that format?
What is the resolved value of Blob.arrayBuffer()?
What is the expected console output of Blob: immutable byte sequences example 1?
(async () => {const b=new Blob(["é"],{type:"text/plain"});console.log(b.size,b.type);})()What is the expected console output of Blob: immutable byte sequences example 2?
(async () => {const b=new Blob(["abcd"]);console.log(await b.slice(1,3).text());})()