programmerjake programmerjake - 5 months ago 8x
Javascript Question

Is a unicode escape valid in the let keyword

Is using a unicode escape sequence valid in the


Restating: Is the following code valid?

l\u0065t a = 1;

Is it equivalent to this code:

let a = 1;



ECMAScript does allow Unicode escape sequences in string literals, template literals and regex literals (so far so expected), and even in identifier names (more details). It does however not allow them in raw source text, so they cannot form things such as keywords, other tokens and whitespaces.

(This has not changed since ES5. You also were not allowed, and continue to be not allowed, to use escape sequences in var.)