Extended Unicode Escapes in Strings Sample

Available in Chrome 44+

When representing Unicode code points outside of the basic multilingual plane in JavaScript string literals, it was previously necessary to use a pair of surrogate code points. Newer browsers support extended Unicode escapes, which allow for a more concise representation of code points in other planes.

For example, the Unicode code point for a "closed umbrella" character is U+1F302. This character can be represented in a JavaScript string literal using the surrogate code point pair \uD83C\uDF02, but in supported browsers, this can be simplified to the single extended Unicode escape, \u{1F302}.

This feature is closely related to String.fromCodePoint(), which was added to Chrome 41. That method provides a programmatic way of translating a code point value into a string, outside the context of a string literal.

Note that in browser which don't support extended Unicode escapes, attempting to use them in JavaScript string literals will trigger syntax errors that cannot be wrapped in a try / catch. Please ensure that you're running under a supported JavaScript environment before using extended Unicode escapes.