Last Updated: February 25, 2016
·
377
· benjamincharity

Make HTML entities browser-readable

function htmlEntities(str) {
    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}