CodingZack is a YouTube channel that I am working on. In this channel, I read the most classic and popular IT books for programmers. After reading each chapter, I will create a video to summarize the key information. And you can finish the book by watch these videos. It should be able to save you a lot of time.
Here is my video for this chapter:
Everything is data in computer.
A chunk of data is called a value.
- Undefined value
1. How to present
1.53e8 => 153,000,000
3 + 5 * 4
(3 + 5) * 4
6 / 3
7 % 3
**Fractional digital numbers are approximations, not precise values.
3. Special Numbers
NaN: Not a Number (0 / 0)
1. Within single or double quotes: “Zack”
2. Escaping: \
Indicates that the character after it has a special meaning.
\n => new line
\t => tab
3. Concatenates: +
“com” + “bina” + “tion”
Unary operator and binary operator
1. Only two values: true, false
console.log(5 > 4)
console.log(5 < 4) > false
3. String comparison
Based on Unicode standard
lowercase > uppercase > number(in quotes as strings) > special characters (!#$)
console.log(“a” > “A”)
console.log(“A” > “1”)
console.log(“abc” < “abd”) > true
console.log(“abc” < “abcd”) > true
4. More comparison operators
>= greater than or equal to
<= less than or equal to
!= not equal to
== equal to
console.log(“Zack” != “Zach”)
5. NaN != NaN
console.log(NaN == NaN)
6. Logical Operator
&& and: only true when both are true
|| or: true when one of them is true
! not: opposite value
console.log(true && false)
console.log(true && true)
console.log(false || true)
console.log(false || false)
Lowest: || < && < Comparison(<,>, == and so on) < others
console.log(true ? 1 : 2);
console.log(false ? 1 : 2);
The value before the question is the condition.
If the condition is true, use the first value.
If the condition is false, use the second value.
4. Undefined Value
undefined: not defined
Automatic Type Conversion
console.log(8 * null)
console.log(“5” – 1)
console.log(“5” + 1)
console.log(“five” * 2)
console.log(false == 0)
console.log(null == undefined)
console.log(null == 0)
Compare something to null with == or != to check if it has a real value rather than null or undefined.
0, NaN and “”(the empty string) equal to false, everything else equals to true.
To avoid auto conversion, use === or !=== for precise comparison
console.log(“” === false)
It’s suggested to use === and !==
Short-Circuiting of Logical Operators
||: if the lefthand side is true, the righthand side will be ignored, return the righthand side right away.
console.log(null || “user”)
console.log(“Karl” || “user”)
&&: if the lefthand side is false, return the lefthand side right away.
The conditional operator(?:): the second or the third value, unpicked one will not be evaluated.
Other two: object and function
– : minus
! : not
typeof : find the type of the value
Arithmetic: + – * / %
Comparison: == != === !=== < > <= >=
Logical && ||
NEXT: Chapter 2 PROGRAM STRUCTURE