Native JavaScript or ES6 way to encode and decode HTML entities?
<p>Is there a native way to encode or decode <a href="https://dev.w3.org/html5/html-author/charref" rel="noreferrer">HTML entities</a> using JavaScript or ES6? For example, <code>&lt;</code> would be encoded as <code>&amp;lt;</code>. There are libraries like <a href="https://www.npmjs.com/package/html-entities" rel="noreferrer"><code>html-entities</code></a> for Node.js but it feels like there should be something built into JavaScript that already handles this common need.</p>