See if you can spot the problem in this variable:
Did you spot the problem? No? It is okay. Take a couple more minutes and see if you can figure it out. Still nothing? I will tell you what is wrong.
You can try it on your own. Copy the code below and paste it in your browser's dev console:
var firstName = "Emilian !";
You should get a "SyntaxError: unexpected token ILLEGAL" message just like in the screen shot above.
Where does it come from?
The line separator is a special character (code point U+2028 and HTML entity
& #8232;) that is used to separate lines instead using of a normal return. It has no width so the browser does not display it. This makes it impossible to see in the text on a regular web page. The same thing will happen if you use a paragraph separator (U+2029).
How did it get in my code?
You most likely copied a code from another website that contained this special character. You can pick it up from any source such as PDF files, Word documents, or any sort of medium that supports Unicode. You can even pick it up from a regular Notepad file or a Tweet.
What other problems can it cause?
Besides the syntax error in your pages, it is possible to have even more problems with JSON APIs.
Also, if you see weird spaces/lines inside of your HTML document then it is most likely an issue with this invisible character, or with its cousin, the zero width space.
What can I do to protect myself?
You just have to be more careful when copying code from another source. Don't assume the code is valid just because it looks right.
Each time you copy something, paste it in your favorite text editor first and then enable an option to show all the non-printing characters. That should show you all of these special characters that would otherwise be invisible. Each editor is different so you will have to search on how to do that for your particular editor.
Another option is to re-write the code by hand (no pasting) inside your own text editor. It takes a bit longer but it is the one way to make sure you are not introducing any special characters into your markup.