Type Conversion and Equality
Always prefer === and !==. Loose == coerces types and surprises beginners.
- === checks value and type.
- Number("42") and String(42) convert explicitly.
- Boolean("") is false; Boolean("0") is true.
console.log(1 === "1");
console.log(1 == "1");
console.log(Number("42"));
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.