Reading the code symbols
The code in this book is set in a font that joins some characters into a single shape. => prints as an arrow and === as one long bar. Nothing changes at the keyboard: you still type the separate characters in the middle column. This key lists every combination that joins somewhere in the book.
Comparison and logic
| Printed glyph | Characters to type | Meaning |
|---|
=== | === | Strict equality. |
!== | !== | Strict inequality. |
!= | != | Loose inequality. The book uses it only as != null, which rules out both null and undefined. |
<= | <= | Less than or equal to, greater than or equal to. |
>= | >= |
&& | && | Logical AND: the right side runs only when the left is truthy. |
|| | || | Logical OR: the right side runs only when the left is falsy. |
?? | ?? | Nullish coalescing: the right side is used only when the left is null or undefined. |
?. | ?. | Optional chaining: the access stops, giving undefined, when the left is null or undefined. |
Functions and types
| Printed glyph | Characters to type | Meaning |
|---|
=> | => | Separates an arrow function’s parameters from its body, or a function type’s parameters from its return type. |
?: | ?: | An optional property or parameter. ? makes it optional, and : starts its type. |
... | ... | Spread or rest. In comments and strings, it just means text left out. |
++ | ++ | Add one, subtract one. In commands, -- starts a long option such as --noEmit. |
-- | -- |
Comments
| Printed glyph | Characters to type | Meaning |
|---|
// | // | Starts a comment that runs to the end of the line. |
/* | /* | Start and end a block comment. |
*/ | */ |
/** | /** | Starts a documentation comment. |
Punctuation that only looks joined
| Printed glyph | Characters to type | Meaning |
|---|
>> | >> | Two or three type-argument lists closing together. |
>>> | >>> |
>] | >] | Closing brackets next to each other. |
}} | }} |
__ | __ | Two underscores in a name. |
.. | .. | The parent folder in a file path. |
--- | --- | The old-file and new-file headers in a diff. |
+++ | +++ |