decode html javascript code example
Example 1: Javascript convert html entity to string
const htmlEntities = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
};
return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);
}
Example 2: unescape html js
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
var Title = $('<textarea />').html("Chris' corner").text();
console.log(Title);
</script>