Quick Reference

Searchable JavaScript and React reference guide

const

Variables

Block-scoped, read-only variable

const PI = 3.14159;

let

Variables

Block-scoped, mutable variable

let count = 0; count++;

var

Variables

Function-scoped, mutable (avoid)

var x = 5;

Arrow Function

Functions

Concise function syntax

const add = (a, b) => a + b;

map()

Arrays

Transform array elements

arr.map(x => x * 2)

filter()

Arrays

Filter array elements

arr.filter(x => x > 5)

reduce()

Arrays

Combine array elements

arr.reduce((sum, x) => sum + x, 0)

Promise

Async

Async operation wrapper

new Promise((resolve, reject) => {})

async/await

Async

Modern async syntax

async function() { await fetch(...); }

Closure

Functions

Access to outer scope

function outer() { const x = 1; return () => x; }

Destructuring

ES6

Extract values from objects/arrays

const { x, y } = obj;

Spread Operator

ES6

Expand iterables

[...arr1, ...arr2]

useState

React Hooks

React state hook

const [state, setState] = useState(0);

useEffect

React Hooks

Side effects in React

useEffect(() => {}, [deps]);

Props

React

Component properties

function MyComponent(props) {}

Virtual DOM

React

React optimization

React renders to Virtual DOM