TestingDocs.com logoTestingDocs.com
Automation learning lab
TestingDocs • Self-paced course

Playwright Automation
Self Study Guide

Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.

60 chaptersBeginner friendlyHands-on practice
JavaScript / Chapter 3 of 60~12 min • Beginner
Chapter 03JavaScript

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

  1. Declare a constant
  2. Declare a changing value
  3. Print the final value

Example

JavaScript
const browser = 'chromium';
let attempts = 0;
attempts += 1;
console.log(browser, attempts);
Expected result: chromium 1
💡 Point to remember
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