Web APIs
FileReader.abort()
Cancel an ongoing FileReader operation. An active read ends with abort and loadend rather than a successful load. Example console output: true true.
Formal Syntax & Structure
javascript syntaxjavascript
reader.abort()Return Value
undefined
No result value.
Working Example
Example Snippetjavascript
(async () => {const r=new FileReader(); const end=new Promise(resolve=>r.addEventListener("loadend",resolve,{once:true})); r.readAsText(new Blob(["hello"])); r.abort(); await end; console.log(r.readyState===FileReader.DONE,r.result===null);})()