JavaScript Playground
Write and run JavaScript code instantly in your browser. Captures console output, errors with line numbers, and execution time. 100% client-side.
Click "Run Code" or press Ctrl+Enter to execute...
JavaScript Quick Reference
| Feature | Syntax | Example |
|---|---|---|
| Arrow Function | const fn = (x) => x * 2 | fn(5) // 10 |
| Template Literal | `Hello ${name}` | `Sum: ${1+2}` // "Sum: 3" |
| Destructuring | const {a, b} = obj | const [x, y] = [1, 2] |
| Spread Operator | [...arr1, ...arr2] | {...obj, key: val} |
| Optional Chaining | obj?.prop?.sub | arr?.[0]?.name |
| Nullish Coalescing | val ?? 'default' | null ?? 'fallback' // "fallback" |
| Async/Await | async function fn() {} | const data = await fetch(url) |
| Promise | new Promise((res, rej) => {}) | Promise.all([p1, p2]) |