-
Numbers, expressions and variables
-
Functions
-
Booleans and conditionals
-
Strings and interpolation
-
Arrays and for of
-
Objects and for in
-
Methods and this
-
Prototypes
-
Events and callbacks
-
Promises
-
Fetch
-
DOM
-
SVG
-
Canvas
-
Audio
If you type a number into the REPL, it'll echo it back to you. That's because the REPL always tells you what value is produced by an expression, and your number is a very simple mathematical expression.
You can do arithmetic in JavaScript the same way as you would with a paper and pen. 1 + 1 = 2. But in JavaScript we can just do the 1 + 1
part, and the interpreter computes 2
.
Here are some math operators you're familiar with:
Operator | Name | Example | Output |
---|---|---|---|
+ |
add | 2 + 2 |
4 |
- |
subtract | 2 - 2 |
0 |
* |
multiply | 2 * 2 |
4 |
/ |
divide | 2 / 2 |
1 |
% |
remainder | 2 % 2 |
0 |
The only one that may need any explanation is remainder. The expression 2 % 2
gives you the remainder of two divided by two, 0
.