Skip to main content

JavaScript

Essential JavaScript methods and ES6+ features

Programming

Array Methods

arr.map(fn)

Transform each element

arr.filter(fn)

Filter elements by condition

arr.reduce(fn, init)

Reduce to single value

arr.find(fn)

Find first matching element

arr.findIndex(fn)

Find index of first match

arr.some(fn)

Check if any element matches

arr.every(fn)

Check if all elements match

arr.includes(val)

Check if array contains value

arr.flat(depth)

Flatten nested arrays

arr.flatMap(fn)

Map then flatten

String Methods

str.split(sep)

Split into array

str.slice(start, end)

Extract portion

str.substring(start, end)

Extract between indices

str.replace(old, new)

Replace first occurrence

str.replaceAll(old, new)

Replace all occurrences

str.trim()

Remove whitespace from ends

str.padStart(len, char)

Pad start to length

str.includes(sub)

Check if contains substring

str.startsWith(sub)

Check if starts with

str.endsWith(sub)

Check if ends with

Object Methods

Object.keys(obj)

Get array of keys

Object.values(obj)

Get array of values

Object.entries(obj)

Get array of [key, value]

Object.assign(target, src)

Copy properties

Object.freeze(obj)

Make object immutable

{ ...obj }

Spread operator (shallow copy)

{ ...obj, key: val }

Spread with override

ES6+ Features

const [a, b] = arr

Array destructuring

const { x, y } = obj

Object destructuring

`Hello ${name}`

Template literals

(a, b) => a + b

Arrow function

async/await

Async function syntax

a ?? b

Nullish coalescing (null/undefined)

a?.b?.c

Optional chaining

{ key }

Shorthand property

Promises & Async

Promise.all(arr)

Wait for all promises

Promise.race(arr)

First promise to settle

Promise.allSettled(arr)

Wait for all, get all results

await promise

Wait for promise resolution

.then().catch().finally()

Promise chaining

Privacy-First Developer Toolkits - 35+ Browser-Based Tools