
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Blob object in JavaScript
The blob object is used for representing a blob object which is immutable and is used for representing raw data. The blob has a size and mime type property just like a file has. File is a derivation of blob and blob can be used in places where the file is used.
Following is the code showing blob object in JavaScript −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result{ font-size: 18px; font-weight: 500; color: rebeccapurple; } </style> </head> <body> <h1>Blob object in JavaScript</h1> <div class="result"></div> <button class="Btn">CLICK HERE</button> <h3>Click on the above button to create and display a blob object</h3> <script> let resEle = document.querySelector(".result"); document.querySelector(".Btn").addEventListener("click", () => { let blob = new Blob(["This is a sample blob"], { type: "text/plain" }); resEle.innerHTML = "blob.type = " + blob.type + "<br>"; resEle.innerHTML += "blob.size = " + blob.size; }); </script> </body> </html>
Output
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
- Related Articles
- Explain BLOB object and tree object in Git.
- How can JavaScript upload a blob?
- How to convert an Image to blob using JavaScript?
- Blob conversion function in Cassandra
- What is BLOB data type in MySQL?
- Object difference in JavaScript
- Map object in JavaScript.
- WeakMap object in JavaScript.
- RegExp object in JavaScript.
- Object initializer in JavaScript
- Converting BLOB to Char in SAP HANA using SQL
- Converting BLOB to Char in SAP HANA using SQL
- How to convert BLOB to Byte Array in java?
- How to use blob data type in Android sqlite?
- Object de-structuring in JavaScript.

Advertisements