Values, variables, operators and control flow
const shop = "BOSS Pacific"; // cannot be reassigned
let count = 0; // can change
// never use var in new code
typeof 42 // "number"
typeof "x" // "string"
typeof null // "object" (a famous historical bug)
0.1 + 0.2 === 0.3 // false — floating point; use integers (cents) for money
Always use strict equality: === and !==.
const status = stock === 0 ? "Out of stock" : stock < 5 ? "Low" : "In stock";
for (const item of cart) { total += item.price * item.qty; }
const name = user?.profile?.name ?? "Guest"; // optional chaining, nullish coalescing
Rating
0
0
There are no comments for now.