JavaScript
Essential JavaScript methods and ES6+ features
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] = arrArray destructuring
const { x, y } = objObject destructuring
`Hello ${name}`Template literals
(a, b) => a + bArrow function
async/awaitAsync function syntax
a ?? bNullish coalescing (null/undefined)
a?.b?.cOptional 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 promiseWait for promise resolution
.then().catch().finally()Promise chaining