PLAYWRIGHTPADQA Practice Platform
Playwright Online IDE
AssessmentsInterview PrepPractice TracksCheatsheetPricing
Log InSign Up
JAVASCRIPT WORKSTATION|Node.js Engine v18|Async QA Mechanics
Module 1 of 10
MODULE 1 OF 10 β€’ THEORY

1. Variables & Scope (let, const)

basic

Use "const" for values that should not change after assignment (like timeouts, URLs, and element selectors). Use "let" for values that will be reassigned (like loop counters, toggle states, and retry accumulators). Avoid "var" because it is function-scoped and can cause leakages.

syntax.js
const TIMEOUT = 5000;
let retryCount = 0;
When to Use

Always prefer const by default. Only use let when you explicitly plan to change the variable's value later in the test execution.

Best Practice

Declare selectors and configuration objects with "const" to prevent accidental runtime reassignments that would break E2E test runs.

Terminal Output
Node.js v18
[Node.js] Ready to execute js-variables.js...
[Node.js] Click "Run Code" to start execution.
Subscriber Access Only

Unlock JavaScript for Automation

Subscribe to access full interactive coursework and labs.

Subscribed users only can access our courses. Subscribe today to unlock complete interactive masterclasses, hands-on coding drills, live sandboxes, and official SDET certification.

Complete Playwright, JavaScript & TypeScript lessons
50+ In-browser interactive drills with live verification
Real-world Banking, Insurance & E-Commerce sandboxes
Official SDET Certificate of Completion
Instant Accessβ€’Cancel Anytimeβ€’7-Day Money Back
Home
Practice Tracks
Practice
Playwright Online IDE