Chapter 0
- "Keeping programs under control is the main problem of programming. When a program works, it is beautiful. The art of programming is the skill of controlling complexity"
- "A sense of what a good program looks like is developed in practice, not learned from a list of rules."
- JavaScript ES6 came out in 2015 and since then there's been small changes each year
- This book uses JS 2017
- "As soon as you no longer use a value, it will dissipate, leaving behind its bits to be recycled as building material for the next generation of values."
Chapter 1: Numbers, Types, and Operators
Numbers
- JS uses 64 bit numbers
- Fractional numbers cannot be represented exactly with 64 bit numbers, occasionally causes problems in specific situations
- Special number values: Infinity, -Infinity, and NaN
Strings
- escape characters using \ (used for quotes, \n, and \t)
- if you truly want a backslash, use two in a row
- JavaScript uses the Unicode standard (110k characters represented by nums) to represent strings
- Unicode assigns every single letter, greek letter, emoji to a number, which can always be represented with bits
- Can use template literals to embed things inside strings and + to concatenate strings
let name = 'hassan'
let hello = `what's up ${name}`
Operators
- Boolean operations: true and false
- 0, "", and NaN are false. Everything else is true. Sometimes null and undefined can be converted to false like in &&
- Logical operators: &&, ||, !, and ?
- The || operator will return the value to its left when that can be converted to true and will return the value on its right otherwise
- && works the exact opposite, when the value to its left is something that converts to false, it returns that value, and otherwise it returns the value on its right.
- Empty values: null and undefined