이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 참여해서 번역을 마치도록 도와 주세요!
English (US)의 문서도 읽어보세요.

Message

SyntaxError: illegal character (Firefox)
SyntaxError: Invalid or unexpected token (Chrome)

Error type

SyntaxError

What went wrong?

There is an invalid or unexpected token that doesn't belong at this position in the code. Use an editor that supports syntax highlighting and carefully check your code against mismatches like a minus sign ( - ) versus a dash () or simple quotes ( " ) vs non-standard quotation marks ().

Examples

Mismatched characters

Some characters look similar, but will cause the parser to fail interpreting your code.

“This looks like a string”;
// SyntaxError: illegal character

42 – 13;
// SyntaxError: illegal character

This should work:

"This is actually a string";

42 - 13;

Forgotten characters

It's easy to forget a character here or there.

var colors = ['#000', #333', '#666'];
// SyntaxError: illegal character

Add the missing quote for '#333'.

var colors = ['#000', '#333', '#666'];

Hidden characters

When copy pasting code from external sources, there might be invalid characters. Watch out!

var foo = 'bar';​
// SyntaxError: illegal character

When inspecting this code in an editor like Vim, you can see that there is actually a zero-width space (ZWSP) (U+200B) character.

var foo = 'bar';​<200b>

See also

문서 태그 및 공헌자

 이 페이지의 공헌자: fscholz
 최종 변경: fscholz,