New string features in ECMAScript 6
The blog post covers new features of strings in ECMAScript 6 (ES6). Unicode code point escapes Unicode “characters” (code points) are 21 bit long [2] . JavaScript strings are (roughly) sequences of 16 bit characters, encoded as UTF-16. Therefore, code points beyond the first 16 bits of the code point range (the Basic Multilingual Pane , BMP) are represented by two JavaScript characters. Until now, if you wanted to specify such code points via numbers, you needed two so-called Unicode escapes . As an example, the following statement prints a rocket (code point 0x1F680) to most consoles: console.log('\uD83D\uDE80'); In ECMAScript 6, there is a new kind of Unicode escape that lets you specify any code point: console.log('\u{1F680}'); String interpolation, multi-line string literals and raw string literals Template strings [3] provide three interesting features. First, template strings support string interpolation: let first = 'Jane'; let last = ...