Skip to content
เข้าสู่ระบบ

Object.freeze

Object.freeze และ as const ทำให้ objects immutable แต่ต่างกัน - Object.freeze เป็น runtime freeze ส่วน as const เป็น compile-time type only

FeatureObject.freezeas constreadonly
Runtime protectionYesNoNo
Type narrowingNoYes (literal)Partial
Deep freezeNo (shallow)YesManual
ArraysPartiallyYesYes

เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม

ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด