introduction
- paraphrasing: the main challenge of prorgamming is managing the complexity of what you’re building
- intereting tangent: “this code runs on any hypothetical machine” or smth ?
ch 1: values
true
and false
are lowercase
- “There is only one value in JavaScript that is not equal to itself, and that is
NaN
(“not a number”).”
- difference between == and === is that === doesn’t try to match types (type coercion). so what they mean by “exactly equal”, at least in js, is “of the same type, and equal” (whereas on the other hand,
0 == false
returns true, e.g.)
- typeof operator to find out types:
typeof x
- 0, NaN, and “” convert to false; all other number and string values convert to true
- i think null and undefined convert to false?
- null and undefined are basically the same
- “when null or undefined occurs on either side of the == operator, it produces true only if both sides are one of null or undefined”
ch 2: prgram structure
- an expression is any bit of code that produces a value, whether that’s just one value itself, or several values with operators between them
- in that sense, a value is “what the expression evaluates to”; ie, the name of a variable is an expression but not a value, since it further evaluates to its content. values can’t contain values, i think (except in the sense of substrings etc); they can’t be further evaluated upon. whereas expressions CAN contain smaller expressions.
- a statement basically just means a line of js, and can be just “an expression followed by a semicolon” (or not even that since apparently those are optional lol); a program is just a series of statements
- “You should imagine bindings as tentacles, rather than boxes. They do not contain values; they grasp them. When you need to remember something, you grow a tentacle to hold on to it or you reattach one of your existing tentacles to it.”
- oh, functions are a type of value too though? (literally, a type) “A function is a piece of program wrapped in a value”
- i guess even the name of a function is just a “binding” or reference or alias—that might be a difference from python?