Quickest way to escape HTML to String

Posted on October 19, 2021

Here the code:

const esc = (v) => {
    var escape = document.createElement('textarea')
    escape.textContent = v
    return escape.innerHTML
}

Found it here.