Example 1 — Demo
Core usage.
JavaScript
const b = new Blob(["hi"], { type: "text/plain" });
console.log(b.size);
console.log(b.type);
b.text().then(console.log);How It Works
- Construct. From parts.
- type. MIME type.
- text(). Decode as UTF-8.
A Blob holds immutable raw data. Files are Blobs. Use text(), arrayBuffer(), or object URLs for previews.
const b = new Blob(["hi"], { type: "text/plain" });
console.log(b.size);
console.log(b.type);
b.text().then(console.log);Core usage.
const b = new Blob(["hi"], { type: "text/plain" });
console.log(b.size);
console.log(b.type);
b.text().then(console.log);CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
6 people found this page helpful