Day 3 of 100: Data Types and the null vs undefined Trap
Day 3 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: JavaScript Fundamentals. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).
🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.
JavaScript has 7 primitive types. QA code touches 5 daily.
Contents
The Types You Use
const name = 'Playwright'; // string
const count = 42; // number
const passed = true; // boolean
const missing = null; // intentional empty
let notSet; // undefined
console.log(typeof name); // 'string'
console.log(typeof count); // 'number'
console.log(typeof missing); // 'object' (historic bug!)
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
null vs undefined — The QA Trap
// API returns null for empty field, undefined for missing field
const user = { name: 'Jane', middleName: null };
console.log(user.middleName); // null — field exists, empty
console.log(user.nickname); // undefined — field absent
// Test assertion difference:
// expect(body.middleName).toBeNull() — explicit empty
// expect(body.nickname).toBeUndefined() — not present
Type Coercion Gotchas
console.log('5' + 3); // '53' — string concat!
console.log('5' - 3); // 2 — numeric subtract
console.log(0 == ''); // true — loose equality lies
console.log(0 === ''); // false — always use ===
Tomorrow (Day 4): Operators and conditionals — the logic of every assertion.
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
