Assertion Functions
Assertion Functions ช่วย narrow types โดยการ throw error ถ้าเงื่อนไขไม่ตรง ต่างจาก type guards ตรงที่ไม่ return boolean
Assertion vs Type Guard
Section titled “Assertion vs Type Guard”| Feature | Type Guard | Assertion |
|---|---|---|
| Returns | boolean | void (หรือ throws) |
| Syntax | is T | asserts |
| Use case | if/else | validate หรือ crash |
Assertion Flow
Section titled “Assertion Flow”เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม
ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด
Login with Google