Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.45 KB

contents.md

File metadata and controls

45 lines (33 loc) · 1.45 KB

Contents

  1. Numbers, expressions and variables

  2. Functions

  3. Booleans and conditionals

  4. Strings and interpolation

  5. Arrays and for of

  6. Objects and for in

  7. Methods and this

  8. Prototypes

  9. Events and callbacks

  10. Promises

  11. Fetch

  12. DOM

  13. SVG

  14. Canvas

  15. Audio

  16. D3 https://square.github.io/intro-to-d3/

Math

Expressions

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.

Operators

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.

Variables