JS Built-ins
Blobintermediate

Blob.slice β€” contentType argument

πŸ“– Usage Example
const b = new Blob(['hello'])
b.slice(-3).text().then(t => t)  // β†’ 'llo'

Negative indices count from the end of the Blob.

Blob.slice() with contentType

blob.slice(start, end, contentType) sets the type of the returned Blob.

Challenge: Verify that new Blob(['hello']).slice(0, 3, 'text/plain').type === 'text/plain'.

πŸ’‘ Hints (1)
  • β€’ The third argument to slice sets the MIME type of the resulting Blob.