|

Day 2 of 100: Variables — let, const, and Why var Is Dead

Day 2 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.


Variables store test data. Three keywords exist. Only two matter.

Contents

let, const, var

const baseUrl = 'https://api.example.com'; // never reassigned
let retryCount = 0;                        // will change
retryCount = 1;                            // fine
// baseUrl = 'x';                          // ERROR: const

// var is function-scoped and hoisted — avoid it
var old = 'do not use';

🚀 Level Up Your Playwright

From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.

Rules for Test Code

  • Default to const — most test data never changes
  • Use let only when reassignment is needed (counters, accumulators)
  • Never use var — its scoping causes subtle bugs in loops
// Real test usage
const testUser = { email: 'qa@test.com', password: 'Secret123!' };
let attempts = 0;
while (attempts < 3) { attempts++; }

Tomorrow (Day 3): Data types — strings, numbers, booleans, null, undefined.

🎓 Master Playwright End to End

Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.