JavaScript Cheatsheet
JavaScript
JS
Programming
Web
Complete reference for JavaScript fundamentals, modern ES6+ features, built-in objects, arrays, functions, and web development techniques.
Quick Reference
📚 Objects & Arrays
Built-in object methods and array manipulation techniques
⚡ Functions & ES6+
Function declarations, arrow functions, and modern syntax
🌐 DOM & Events
Document manipulation and event handling
🔄 Async & APIs
Promises, async/await, and API interactions
Variables and Data Types
JavaScript is a dynamically typed language with several primitive and non-primitive data types.
Variable Declarations
Variable declaration methods
Primitive Data Types
Basic data types
Non-Primitive Data Types
Complex data types
Object Methods
JavaScript Objects are collections of key-value pairs with powerful built-in methods for manipulation and inspection.
Object Static Methods
Object creation and property management
Object state management
Object Instance Methods
Property checking and conversion
Array Methods
Arrays in JavaScript come with powerful methods for manipulation, iteration, and transformation. Understanding these is crucial for effective JavaScript programming.
Array Creation and Static Methods
Creating arrays
Mutator Methods (Modify Original Array)
Adding and removing elements
Array manipulation
Accessor Methods (Return New Array/Value)
Array searching and extraction
Iteration Methods
Array transformation and filtering
Array iterators
Functions
Functions are first-class objects in JavaScript, meaning they can be stored in variables, passed as arguments, and returned from other functions.
Function Declarations and Expressions
Different ways to define functions
Function Parameters and Arguments
Advanced parameter handling
Higher-Order Functions
Functions that work with other functions
ES6+ Modern Features
ES6 and later versions introduced many features that make JavaScript more powerful and expressive. These are essential for modern JavaScript development.
Template Literals and String Methods
Enhanced string handling
Destructuring Assignment
Extract values from arrays and objects
Classes and Objects
Modern class syntax
Modules (Import/Export)
Module system
Asynchronous JavaScript
Asynchronous programming is crucial for handling operations like API calls, file reading, and timers without blocking the main thread.
Promises
Working with Promises
Async/Await
Modern asynchronous syntax
DOM Manipulation
The Document Object Model (DOM) provides an interface for interacting with HTML elements in web pages.
Element Selection
Finding elements in the DOM
Element Manipulation
Modifying DOM elements
Creating and Inserting Elements
Adding new elements to the DOM
Event Handling
Handling user interactions
Error Handling
Proper error handling is essential for building robust JavaScript applications that can gracefully handle unexpected situations.
Try-Catch-Finally
Handling errors gracefully
Best Practices
Follow these JavaScript best practices for writing clean, maintainable, and efficient code.
- Use
const
by default,let
when reassignment is needed, avoidvar
- Prefer arrow functions for short functions and callbacks
- Use template literals instead of string concatenation
- Destructure objects and arrays to extract values cleanly
- Handle errors properly with try-catch blocks and proper error messages
- Use async/await instead of promise chains for better readability
- Validate inputs and handle edge cases in your functions
- Use meaningful variable and function names that describe their purpose
- Keep functions small and focused on a single responsibility
- Use modern array methods like
map
,filter
,reduce
instead of loops when appropriate
Learn More
Explore comprehensive JavaScript documentation and advanced programming techniques
Written by
Deepak Jangra
Created At
Wed Jan 15 2025
Updated At
Fri Jun 13 2025