1const htmlEntities = {
2 "&": "&",
3 "<": "<",
4 ">": ">",
5 '"': """,
6 "'": "'"
7 };
8return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);
9}
10
1const htmlEntities = {
2 "&": "&",
3 "<": "<",
4 ">": ">",
5 '"': """,
6 "'": "'"
7 };
8return str.replace(/([&<>\"'])/g, match => htmlEntities[match]);