strings
What happens when a value is legitimately zero
That question is why ?? exists
Templates
const name = "mahmoud";
console.log(`${name}`.toUpperCase());
Backticks allow interpolation Ordinary quotes do not
Operators worth knowing
5 % 2 // 1
0 ?? "no" // 0
null ?? "no" // "no"
1 === "1" // false
?? only falls back on null or undefined
|| falls back on every falsy value , including zero and empty string
Using || for a port number is how you silently replace 0
Optional chaining
const user = { name: "Ada" };
console.log(user?.address);
Output:
undefined
No exception That is the point
Comparison
== converts types before comparing
=== does not
Use === until you have a specific reason not to
Next
Branching in 03 decisions
Posted