eloquent javascript 2nd edition chapter 1 Values, Types, and Operators
Values
Numbers
Arthmetic
special numbers
String
Strings cannot be divided, multiplied, or subtracted, but the
+
operator can be used on them.
Unary Operator
It takes only one value.
produces a string value naming the type of the value you give it.
FYI, Binary Operator
It takes two values. - can be both, unary and binary opertor, minus and negative.
Boolean Values
produce true or false
comparison
Other similar operators are
>=
(greater than or equal to),<=
(less than or equal to),==
(equal to), and!=
(not equal to).
Strings can be compared.
The way strings are ordered is more or less alphabetic: uppercase letters are always “less” than lowercase ones, so
"Z" < "a"
is true.
logical operators
Conditional Operator
ternary, it takes three values.
pick one of two values based on a third value.
console.log(true ? 1 : 2); // → 1 console.log(false ? 1 : 2); // → 2
Undefined Value
that are used to denote the absence of a meaningful value. They are themselves values, but they carry no information.
The difference in meaning between
undefined
andnull
is an accident of JavaScript’s design, and it doesn’t matter most of the time.
この章はエクササイズなし。
この動画も並行してみると理解が早い。
ただし英語が聞き取りにくいのと、
かなり遅いので、2倍速再生字幕付きでみました。
ちょっと考えた事。
logical operator を眺めていて、ふと思った事。
or のオペレーター、
って、
と同じなのかしら?と思ったのだが結論は、
似ているけどちがう。
変数代入の右側は絶対に式じゃないとダメ
意味合いは似ているけれど、文法的には決定的に異なる。
だから、同じものではない。
ということでした。