How to Encode html entities in javascript

Here is a breakdown to encode html entities in javascript.This will help you understand how HTML entities can be encoded in javascript with ease which you can use as well. You can use regex to replace any character in a given unicode range with its html entity equivalent. The code would look something like this: