It can be difficult to create or output some characters as JavaScript TextNodes. Typically you might try to use the ampersand notation, unfortunately the ampersand itself gets escaped to & as such
becomes
Use of the Unicode notation can easily resolve this issue.
Example for NBSP:
var nsbptextnode = document.createTextNode('\u00A0');