Back to Cheat SheetsLanguage · Beginner

JavaScript cheat sheet

Modern ES syntax, async handling and array methods used in Playwright and Cypress tests.

Essentials

Destructure

const { id, name } = user;

Spread

const next = { ...user, name: 'QA' };

Optional chaining

user?.profile?.email ?? 'none'

Template literal

`/api/users/${id}`

Arrays

map / filter / find

xs.map(f); xs.filter(f); xs.find(f)

reduce

xs.reduce((acc, x) => acc + x, 0)

includes

xs.includes('smoke')

Async

await

const res = await fetch(url);

Parallel

await Promise.all([a(), b()])

Error handling

Unawaited promises silently pass tests

try { await f(); } catch (e) { }

Go beyond the reference

Book a free demo class and apply these commands on live project work.