Cheat Sheets

JavaScript Cheat Sheet

Quick reference for JavaScript — variables, types, functions, arrays, objects, classes, promises, async/await, and the Fetch API.

Dynamic. Async. Everywhere.

Variables & Types
letconstvartypeofnull vs undefinedTemplate literals
Operators
ArithmeticStrict equalityLoose equalityLogical AND / ORNullish coalescing (??)Optional chaining (?.)TernarySpread (...)Destructuring
Strings
lengthtoUpperCase / toLowerCasetrim()includes()startsWith / endsWithslice()replace()split()padStart / padEndrepeat()
Arrays
push / popunshift / shiftmap()filter()reduce()find() / findIndex()includes()some() / every()flat() / flatMap()slice()splice()sort()forEach()Array.from()
Objects
Object literalShorthand propertyComputed propertyOptional chainingObject.keys()Object.values()Object.entries()Object.assign()Spread mergedelete operator
Functions
Function declarationFunction expressionArrow functionDefault parametersRest parametersCallbackIIFE
Conditionals & Loops
if / else if / elseswitchfor loopfor...offor...inwhile / do-whilebreak / continue
Classes
Class definitionInheritanceStatic methodGetter / SetterPrivate fields (ES2022)
Modules (ES6)
Named exportDefault exportNamed importDefault importRename importImport all
Promises
Create.then().catch().finally()Promise.all()Promise.allSettled()Promise.race()
Async / Await
async functionawaittry / catch errorsParallel with await
Fetch API
GET requestPOST requestCheck statusResponse methods
Error Handling
try / catch / finallythrowError types