Quick Reference
Searchable JavaScript and React reference guide
const
VariablesBlock-scoped, read-only variable
const PI = 3.14159;let
VariablesBlock-scoped, mutable variable
let count = 0; count++;var
VariablesFunction-scoped, mutable (avoid)
var x = 5;Arrow Function
FunctionsConcise function syntax
const add = (a, b) => a + b;map()
ArraysTransform array elements
arr.map(x => x * 2)filter()
ArraysFilter array elements
arr.filter(x => x > 5)reduce()
ArraysCombine array elements
arr.reduce((sum, x) => sum + x, 0)Promise
AsyncAsync operation wrapper
new Promise((resolve, reject) => {})async/await
AsyncModern async syntax
async function() { await fetch(...); }Closure
FunctionsAccess to outer scope
function outer() { const x = 1; return () => x; }Destructuring
ES6Extract values from objects/arrays
const { x, y } = obj;Spread Operator
ES6Expand iterables
[...arr1, ...arr2]useState
React HooksReact state hook
const [state, setState] = useState(0);useEffect
React HooksSide effects in React
useEffect(() => {}, [deps]);Props
ReactComponent properties
function MyComponent(props) {}Virtual DOM
ReactReact optimization
React renders to Virtual DOM