It's hard to belive that JavaScript still does not have standard function to encodeHTML to string (as in replace < and > etc with < etc). I know this can be solved by other wasy (as in never using innerHTML), but in reality it's often ignored or just custom implementations put in place.