JavaScript Cheat Sheet
Essential JavaScript concepts, ES6+ features, and common methods.
3 PagesBeginnerMay 18, 2026
Variables
Three ways to declare variables.
javascript
const name = "SkillVeris"; // Cannot reassignlet count = 0; // Can reassignvar old = "legacy"; // Avoid (function-scoped)
Data Types
JavaScript has 8 primitive types.
- string- Text values
- number- Integers and floats
- boolean- true or false
- null- Intentional empty value
- undefined- Uninitialized variable
- object- Key-value collection
- array- Ordered list
- symbol- Unique identifier
Array Methods
Common ES6 array manipulation.
javascript
const nums = [1, 2, 3, 4, 5];const doubled = nums.map(n => n * 2);const evens = nums.filter(n => n % 2 === 0);const sum = nums.reduce((a, b) => a + b, 0);const found = nums.find(n => n > 3); // 4
Promises & Async
Handle asynchronous operations.
javascript
// Async/Awaitasync function fetchData(url) { try { const res = await fetch(url); const data = await res.json(); return data; } catch (err) { console.error(err); }}
Destructuring & Spread
Unpack arrays/objects and expand with spread.
javascript
const [first, ...rest] = [1, 2, 3]; // first=1, rest=[2,3]const { name, age = 18 } = user; // default valueconst merged = { ...defaults, ...opts };const copy = [...arr];function sum(...nums) { return nums.reduce((a, b) => a + b, 0);}const { data: payload } = res; // rename
Arrow Functions & this
Concise functions with lexical this binding.
javascript
const double = x => x * 2;const add = (a, b) => a + b;const make = () => ({ ok: true }); // return object literal// arrows keep the surrounding thisclass Timer { count = 0; start() { setInterval(() => this.count++, 1000); }}
Object & JSON Utilities
Common Object static methods and JSON handling.
javascript
const o = { a: 1, b: 2 };Object.keys(o); // ['a', 'b']Object.values(o); // [1, 2]Object.entries(o); // [['a',1], ['b',2]]Object.assign({}, o, { c: 3 });const frozen = Object.freeze(o);const str = JSON.stringify(o, null, 2);const back = JSON.parse(str);
Equality & Operators
Comparison and modern logical operators.
- === / !==- strict equality, no type coercion; prefer over ==
- ?? (nullish)- returns right side only when left is null or undefined
- ?. (optional chain)- safely access nested props; short-circuits on null/undefined
- ||= &&= ??=- logical assignment operators that assign conditionally
- typeof / instanceof- check primitive type name / prototype chain membership
Async/Await Patterns
Awaiting, parallelism, and error handling.
javascript
async function load(id) { try { const res = await fetch(`/api/${id}`); if (!res.ok) throw new Error(res.status); return await res.json(); } catch (e) { console.error(e); }}// run in parallelconst [a, b] = await Promise.all([load(1), load(2)]);
Pro Tip
Prefer const over let and let over var. Use optional chaining (?.) to safely access nested properties.
Was this cheat sheet helpful?
Explore Topics
#JavaScript#JavaScriptCheatSheet#Programming#Beginner#Variables#DataTypes#ArrayMethods#PromisesAsync#Functions#CheatSheet#SkillVeris