Web APIs

TextDecoder.fatal

Try the free JavaScript compiler

Report whether invalid input causes decoding to throw rather than produce replacement characters. Select fatal mode when invalid byte sequences must be rejected. Example console output: true true.

Formal Syntax & Structure

javascript syntaxjavascript
decoder.fatal

Return Value

boolean

Fatal error mode.

Working Example

Example Snippetjavascript
const d=new TextDecoder("utf-8",{fatal:true}); let rejected=false; try{d.decode(Uint8Array.of(255))}catch(e){rejected=e instanceof TypeError} console.log(d.fatal,rejected);
JavaScript Reference