I want to display a text to HTML by a javascript function. How can I escape html special chars in JS? Is there an API ?
If you already use modules in your app, you can use escape-html module.
import escapeHtml from 'escape-html'; const unsafeString = ''; const safeString = escapeHtml(unsafeString);