Mr.D
Mr.D

Reputation: 7893

Javascript SyntaxError: Unexpected token ILLEGAL when trying to use emoji's UTF code

I wanted to add emoji to my string as UTF-8 code:

var c11 = new Road('/hl','\u{1F1F3-1F1F1} netherlands', node4);

According to link, It is Netherlands flags emoji UTF-8 code. When I started my javascript app it throws me this error:

var c11 = new Road('/hl', '\u{1F1F3-1F1F1} netherlands', node4);
                     ^^^^^^^^^

SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)

When I write other emojis which has no dash symbol (for example \u{1F338}) it works nice. Why I can't use flags?

Upvotes: 1

Views: 531

Answers (1)

Timo Türschmann
Timo Türschmann

Reputation: 4696

Just use \u{1F1F3}\u{1F1F1} instead of \u{1F1F3-1F1F1}.

Upvotes: 2

Related Questions