Chapter 03: Variables and constants
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Variables and constants
A variable stores a value for later use. let permits reassignment while const prevents reassignment of the binding. A const object can still have its properties changed. Prefer const for values that are not reassigned.
How it works
Step-by-step walkthrough
- Declare a constant
- Declare a changing value
- Print the final value
Example
const browser = 'chromium';
let attempts = 0;
attempts += 1;
console.log(browser, attempts);Avoid var in new beginner projects unless studying legacy code.
✎ Your practice task
Add another attempt and predict the result.
Knowledge check
Which declaration allows reassignment?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.