Cheat Sheets

JavaScript Cheat Sheet (2026): Syntax, ES6+, Arrays & DOM

By ArpaNeuro Team September 7, 2026
JavaScript JS cheat sheet

A JavaScript cheat sheet is a compact map of the language you run in the browser and in Node.js. This page focuses on modern syntax (let/const, arrows, modules), the array methods you use every day, and async code with fetch and async/await.

This JavaScript cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.

Quick reference

  • Declare: const by default, let when reassigned, never var in new code.
  • Types: string, number, bigint, boolean, null, undefined, symbol, object.
  • Equality: === and !==. Use Object.is for edge NaN checks.
  • Arrows: () => value inherits this. Use function when you need a constructable method.
  • Template: ` Hello ${name} ` for strings. Never build HTML from raw user input.
  • Destructure: const {title, slug} = post; and const [first, ...rest] = list.
  • Spread: {...a, ...b} and [...items, next].
  • Optional: user?.address?.city and value ?? fallback (nullish, not falsy).
  • JSON: JSON.parse / JSON.stringify. Wrap parse in try/catch.
  • Modules: export function x(){} and import {x} from "./x.js" with type="module".

Copy-paste examples

Filter, map, and reduce

Prefer these over hand-rolled for-loops when transforming lists.

const orders = [
  { id: 1, total: 20, paid: true },
  { id: 2, total: 45, paid: false },
  { id: 3, total: 15, paid: true },
];
const paidTotal = orders
  .filter((o) => o.paid)
  .map((o) => o.total)
  .reduce((sum, n) => sum + n, 0);
console.log(paidTotal); // 35

Fetch JSON with async/await

Always check res.ok before calling .json().

async function loadProjects() {
  const res = await fetch('/api/projects.php?public=1');
  if (!res.ok) throw new Error('HTTP ' + res.status);
  const data = await res.json();
  return data.projects ?? [];
}

Common mistakes

  • Using == and accidentally coercing "", 0, and false into equality bugs.
  • Mutating arrays with sort() in place when you needed [...list].sort().
  • Forgetting await and logging a Promise object instead of data.
  • Attaching listeners in a loop without { once: true } or abort controllers — duplicate handlers.
  • Storing objects in localStorage without JSON.stringify / JSON.parse.

FAQ

  1. Is JavaScript the same as Java? No. Different languages, different runtimes, similar names by accident. JavaScript runs in browsers and Node. Java runs on the JVM.
  1. Should I learn vanilla JS before React? Yes. React is JavaScript. If you cannot debug an event listener or a fetch call, components will feel like magic.
  1. What is the event loop in one sentence? JavaScript runs one call stack; async callbacks and promises queue as macrotasks/microtasks and run when the stack is empty.
  1. Do I need TypeScript? For apps that last, yes. For a first cheat-sheet week, master JS types and === first, then add TypeScript.

Related JavaScript cheat sheets

Build with this stack

When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds custom web development and also sells ready-made source code. Request a quote and tell us the stack.

Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.

← All Articles Get a Quote →