ชีตสรุป JavaScript
ข้อมูลอ้างอิงที่ค้นหาและพิมพ์ได้ของ JavaScript สมัยใหม่ — ไวยากรณ์ อาร์เรย์ สตริง ออบเจกต์ async/await DOM และฟีเจอร์ ES2022+ ฟรี
Variables & types
10let x = 1;
const PI = 3.14;
typeof value
Number('42')
String(42)
parseInt('42px', 10)
Boolean(0)
value ?? 'default'
a?.b?.c
Array.isArray(x)
Functions
9function add(a, b) { return a + b; }
const add = (a, b) => a + b;
const f = (a = 1) => a;
function f(...args) {}
f(...arr)
const { a, b } = obj;
const [x, y] = arr;
(function(){})()
fn.bind(this)
Strings
10`Hello ${name}`
str.length
str.includes('a')
str.slice(0, 3)
str.replace(/a/g, 'b')
str.split(',')
str.trim()
str.toUpperCase()
str.padStart(3, '0')
str.at(-1)
Arrays
11arr.map(x => x * 2)
arr.filter(x => x > 0)
arr.reduce((a, b) => a + b, 0)
arr.find(x => x.id === 1)
arr.some(x => x > 0)
arr.every(x => x > 0)
arr.includes(3)
arr.sort((a, b) => a - b)
[...new Set(arr)]
arr.flat(Infinity)
arr.at(-1)
Objects
9Object.keys(obj)
Object.values(obj)
Object.entries(obj)
{ ...a, ...b }
Object.assign({}, a, b)
Object.freeze(obj)
{ [key]: value }
obj.hasOwnProperty('x')
structuredClone(obj)
Async & promises
9async function f() {}
await fetch(url)
Promise.all([p1, p2])
Promise.allSettled([p1, p2])
Promise.race([p1, p2])
new Promise((res, rej) => {})
try { await f(); } catch (e) {}
setTimeout(fn, 1000)
queueMicrotask(fn)
Control flow
9if (a) {} else if (b) {} else {}
a ? b : c
switch (x) { case 1: break; }
for (const x of arr) {}
for (const k in obj) {}
while (cond) {}
arr.forEach((x, i) => {})
break / continue
label: for (...) { break label; }
DOM & events
10document.querySelector('.x')
document.querySelectorAll('.x')
el.addEventListener('click', fn)
el.classList.toggle('active')
el.dataset.id
el.textContent = 'hi'
el.setAttribute('aria-hidden', true)
e.preventDefault()
el.closest('.parent')
document.createElement('div')
Classes & modules
9class A extends B {}
constructor() { super(); }
#private = 1;
static create() {}
get value() {}
export default fn;
export { a, b };
import x, { y } from './m.js'
const m = await import('./m.js')
ไม่มีรายการที่ตรงกับ “:q”
เกี่ยวกับ ชีตสรุป JavaScript
เอกสารสรุป JavaScript นี้เป็นข้อมูลอ้างอิงหน้าเดียวที่ค้นหาได้สำหรับภาษาสมัยใหม่: ตัวแปรและชนิดข้อมูล ฟังก์ชัน string อาร์เรย์ อ็อบเจ็กต์ async และ promise การควบคุมโฟลว์ DOM และเหตุการณ์ รวมถึงคลาสและโมดูล แต่ละรายการจับคู่สนิปเป็ตโค้ดจริงกับคำอธิบายหนึ่งบรรทัดว่ามันทำอะไร
มันเขียนขึ้นสำหรับ JavaScript ที่ผู้คนใช้งานจริงในปัจจุบัน — let และ const, arrow function, destructuring, spread, optional chaining, template literal, async/await และ ES module — ทำให้มันเป็นตัวทบทวนที่รวดเร็วเมื่อคุณสลับกลับมาจากภาษาอื่น
เอกสารทั้งหมดโหลดฝั่ง client และใช้งานฟรี กรองแบบสดด้วยกล่องค้นหา ข้ามไปมาระหว่างส่วนต่าง ๆ จากสารบัญที่ติดอยู่บนหน้า คลิกสนิปเป็ตใด ๆ เพื่อคัดลอก และพิมพ์หน้าเพื่อเก็บไว้เป็นข้อมูลอ้างอิง JavaScript ข้างโต๊ะทำงาน
วิธีใช้ ชีตสรุป JavaScript
- เปิดเอกสารและไล่ดูรายการส่วน — ตั้งแต่ Variables & types ผ่าน DOM & events ไปจนถึง Classes & modules
- พิมพ์ลงในกล่องค้นหาเพื่อกรองทุกแถวแบบสด ตัวนับผลลัพธ์จะแสดงจำนวนสนิปเป็ตที่ตรงกัน
- ใช้สารบัญที่ติดอยู่บนหน้าเพื่อกระโดดไปยังส่วนอย่าง Async & promises โดยตรง
- คลิกสนิปเป็ตหรือไอคอนคัดลอกของมันเพื่อคัดลอกโค้ดไปยังคลิปบอร์ดของคุณ
- คลิก Print เพื่อพิมพ์สำเนาข้อมูลอ้างอิงทั้งหมดในรูปแบบที่เหมาะกับกระดาษ