Decoding HTML Entities in JavaScript/TypeScript
| Category | programming | |
| Tags | ||
| Created | ||
| Last Updated |
Decoding HTML Entities in JavaScript/TypeScript
There is no built-in function to perform this operation so we can get the job done by appending the text to a virtual textarea and getting its value back.
ts1 2 3 4 5const decodeHtml = (html: string) => { const textarea = document.createElement('textarea'); textarea.innerHTML = html; return textarea.value; };