JavaScript Cheatsheet

JavaScript fundamentals, async patterns, and ES6+ features for web development

Programming Language6 commandsintermediate

Overview

JavaScript is a versatile programming language that runs in browsers and Node.js environments.

Why It Matters

JavaScript powers interactive web applications and increasingly runs on servers with Node.js.

Essential Commands

node app.js

Run JavaScript file with Node.js

npm install

Install package dependencies

npm run dev

Start development server

npm run build

Build production assets

npm test

Run test command from package.json

node --watch app.js

Run script and restart on file changes

npx eslint .

Run linter on current directory

npx prettier --write .

Format code with Prettier

npx tsc

Compile TypeScript to JavaScript

npx jest

Run tests with Jest

npx webpack

Bundle JavaScript with Webpack

npx create-react-app my-app

Bootstrap a new React application

npx express-generator my-api

Generate a new Express.js API project

npx next dev

Start Next.js development server

npx next build

Build Next.js application for production

npx next start

Start Next.js application in production mode

npx create-next-app my-next-app

Bootstrap a new Next.js application

npx ts-node script.ts

Run TypeScript file directly with ts-node

npx nodemon app.js

Run Node.js app with automatic restarts on file changes

Quick Start

Master master promises and async/await first

Key Concepts

Master promises and async/await

Understand closures and scope

Learn ES6+ syntax and array/object methods

Pro Tips

  • Combine multiple commands for powerful workflows
  • Use aliases to speed up your command entry
  • Create scripts to automate repetitive tasks

Common Pitfalls to Avoid

  • Forgetting to check the documentation for edge cases
  • Running commands without understanding their full impact
  • Not testing changes in a safe environment first

Related Resources

12 items