Check out example codes for "javascript html special characters". It will help you in understanding the concepts better.

Code Example 1

return mystring.replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");

Learn ReactJs, React Native from akashmittal.com