8 JavaScript Mistakes I See in Every Code Review (And How to Fix Them)
After reviewing hundreds of PRs, these are the patterns that keep coming up. Let's fix them once and for all. 1. Using == instead of === // 🚫 Wrong - type coercion is unpredictable if (user.age ==...

Source: DEV Community
After reviewing hundreds of PRs, these are the patterns that keep coming up. Let's fix them once and for all. 1. Using == instead of === // 🚫 Wrong - type coercion is unpredictable if (user.age == "18") ... if (count == null) ... if (0 == false) ... // true! if ("" == false) ... // true! // ✅ Correct - strict equality, no surprises if (user.age === 18) ... if (count === null || count === undefined) ... // Or better: if (count == null) ... // Only acceptable for null/undefined check Exception: == null is fine when checking for both null AND undefined. 2. Mutating function parameters // 🚫 Wrong - mutates the caller's object function addTimestamp(user) { user.createdAt = new Date(); return user; } const admin = { name: 'Alice', role: 'admin' }; const timestamped = addTimestamp(admin); console.log(admin.createdAt); // Oops! admin was mutated too // ✅ Correct - return a new object function addTimestamp(user) { return { ...user, createdAt: new Date() }; } 3. Not handling async errors // 🚫