We use // for single-line comments and /* ... */ for multi-line comments.
Variable names are case-sensitive (age and Age are treated as different variables).
| Variable Name | Valid? | Why? |
|---|---|---|
first-name |
❌ Wrong | Hyphens are treated as minus signs. |
firstName |
✅ Correct | CamelCase format (Best Practice). |
99name |
❌ Wrong | Cannot start with a number. |
name99 |
✅ Correct | Numbers are allowed in the middle or end. |
let |
❌ Wrong | Reserved keyword in JavaScript. |
first name |
❌ Wrong | Spaces are not allowed. |
first_name |
✅ Correct | Snake_case format using underscores. |
varvar (Redeclaration & Scope)letUnlike var, you cannot redeclare the same variable name using let in the same scope, and it respects block scope.
const (Constants)With const, you declare a variable whose value cannot be changed or reassigned later.