Web APIs

FileReader.prototype.readAsText()

Try the free JavaScript compiler

Starts an asynchronous text read; the completed result is delivered through events.

Formal Syntax & Structure

javascript syntaxjavascript
reader.readAsText(blob, encoding)

Parameters & Attributes

NameTypeDescription
blobBlobSource data.
encodingstringOptional encoding label.

Return Value

undefined

Starts an asynchronous text read; the completed result is delivered through events.

Working Example

Example Snippetjavascript
(async () => {const r=new FileReader();const out=await new Promise((resolve,reject)=>{r.onload=()=>resolve(r.result);r.onerror=()=>reject(r.error);r.readAsText(new Blob(["abc"]));});console.log(out,r.readyState);})()
JavaScript Reference