const vs let vs varvar due to variable hoisting and scope leak issues:
- const: For values that remain fixed during test runs (Base URLs, selectors, timeouts).
- let: For values that change dynamically (retry counts, loop indices, status flags).const baseUrl = "https://targetqa.com";
let retryAttempts = 0;
retryAttempts += 1;string: Test locators, text assertions ("Sign In").
2. number: Element counts, status codes (200, 5000).
3. boolean: Element states (true, false).
4. null: Deliberate empty value.
5. undefined: Unassigned variable.// Loop through test items with for...of:
const menuItems = ["Dashboard", "Orders", "Settings"];
for (const item of menuItems) {
console.log("Validating navigation item: " + item);
}// Inspect configuration keys with for...in:
const config = { browser: "chromium", headless: true };
for (const key in config) {
console.log(key + ": " + config[key]);
}