The Journey of #100DaysOfCode (Baqer_Qabalan)

Day 4: What is a Blob?

A Blob (Binary Large Object) in JavaScript represents raw binary data, like images or files. It’s often used to handle and store large amounts of data, allowing web applications to read, save, and send this data efficiently.

How to use it?

const jsonData = { name: "John", age: 30 };
const jsonString = JSON.stringify(jsonData);
const jsonBlob = new Blob([jsonString], { type: 'application/json' });

console.log(jsonBlob);

In this code, first, the JSON data is converted into a string using JSON.stringify(). Then, this stringified JSON data is used to create a Blob with a JSON file.

100daysofcode lebanon-mug

3 Likes