Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

htmlEntities for JavaScript

htmlentities() is a PHP function which converts special characters (like <) into their escaped/encoded values (like <). This allows you to show to display the string without the browser reading it as HTML.

      
  function htmlEntities(str) {
      return String(str).replace(/&/g, '&').replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
  }