#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
🟨 FREE · 44 SNIPPETS

JavaScript Cheat Sheet: Modern JS at a Glance

ES6+ syntax, array methods, async code and DOM basics, with tested results.

  • 🧮 Array methods
  • ⏳ Async/await
  • ✅ Results tested

How to use the JavaScript Cheat Sheet

  1. 1. Search or browseType a word like the function or task you need, or pick a section.
  2. 2. CopyEach snippet has its own Copy button, so you can paste it straight into your editor.
  3. 3. DownloadSave the whole JavaScript cheat sheet as plain text or Markdown for offline revision.

What's in it

The sheet covers modern JavaScript for both the browser and Node.js, including quirks interviewers like to ask about. The 44 snippets are organised into 11 sections: Basics, Strings, Arrays, Objects, Functions, Async, DOM, Classes, Modules, Dates, Numbers.

Every snippet that shows a result (marked with →) was run in Node.js, and the output matches what's shown.

Example

Search "sort" and you'll see [5, 1, 10].sort((a, b) => a - b) → [1, 5, 10]. Without the compare function, sort compares items as text and would give [1, 10, 5]. Search "??" to see the difference between null ?? "default" and 0 || "fallback": ?? only replaces null and undefined, while || also replaces 0 and empty strings.

Tips for using it

  • Paste any snippet into your browser console to experiment.
  • The DOM section's last tip matters for security: set textContent, not innerHTML, for user input.

A quick look, one snippet per section

  • Basics: const x = 5; let y = 10; (const can't be reassigned; let can (both block-scoped))
  • Strings: "Uncodemy".slice(1, 4) (part of a string)
  • Arrays: [1, 2, 3].map(x => x * 2) (transform each item)
  • Objects: const { name, age = 18 } = user; (destructuring with a default)
  • Functions: const add = (a, b = 0) => a + b; (arrow function with a default parameter)
  • Async: await fetch(url).then(r => r.json()) (fetch JSON)
  • DOM: document.querySelector("#id .item") (find the first matching element)
  • Classes: class Dog extends Animal { #secret = 1; constructor(n) { super(n); } } (class with a private field)
  • Modules: export default App; import App, { helper } from "./app.js"; (eS module export and import)

Search the box above for the rest of the JavaScript snippets, or download the full sheet.

Frequently asked questions

Is TypeScript included?

No. See the TypeScript cheat sheet.

Does it cover Node.js APIs?

Only the parts shared with browsers, like fetch, timers and modules.

Is the JavaScript cheat sheet free?

Yes. You can search, read and copy every snippet in the JavaScript cheat sheet without signing up. The first time you download it, we ask once for your name and WhatsApp number; after that downloads and every other Uncodemy tool open straight away.

More free tools

See all free tools