QuickDevGuide

Home › JavaScript

Variables, Data Types & Type Conversion — JavaScript

Variable Declarations JavaScript has three ways to declare variables. let declares a block-scoped variable that can be reassigned. const declares a block-scoped variable that cannot be reassigned (but objects/arrays it holds CAN be mutated). var is the legacy keyword — it is function-scoped and hoisted, leading to subtle bugs. Rule: always use const by default, use let when you need to reassign, never use var. Data Types JavaScript has 8 data types. Primitive types are immutable values passed by copy: String ("hello"), Number (42, 3.14 — no separate integer type), BigInt (very large integers), Boolean (true/false), undefined (declared but not yet assigned), null (intentionally empty), and Symbol (unique identifiers). Reference types are mutable and passed by reference: Object ({key…

Key Takeaways