

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Learn JavaScript
incomplete
2: Basic Variables
incomplete
3: let and const
incomplete
4: Why JavaScript?
incomplete
5: Comments
incomplete
6: Numbers in JS
incomplete
7: Numbers Review
incomplete
8: Increment and Decrement
incomplete
9: Undefined vs. Undeclared
incomplete
10: Null vs. Undefined
incomplete
11: Dynamic and Weak
incomplete
12: Same Line Declarations
incomplete
13: JavaScript's Speed
incomplete
14: Strings
incomplete
15: Template Literals
incomplete
16: Java vs. JavaScript
incomplete
17: Semi-Colons in JS
incomplete
18: String Encoding
incomplete
19: Camel Case in JS
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
In JavaScript, strings consist of UTF-16 code units - which basically means that most characters are represented by a 16-bit number (2 bytes). This allows for more than just the 128 ASCII characters, but also characters from non-English languages and other symbols.
Some characters (like emojis 😀) require more than 16 bits to represent, so JavaScript uses a pair of 16-bit numbers (2 code units) to represent them.
Long story short, you're generally safe to use unicode characters (like emojis) in your strings. Just be aware that some characters will take up more than one "character" in the string. This is totally chill:
const kermit = "🐸";
Interactive example available with JavaScript enabled.
name variable with the bear emoji ('🐻') and run the code again.