Core JavaScript fundamentals including variables, data types, operators, control flow, and basic syntax. Essential foundation for all JavaScript development.
// Nullish coalescing
const name = input ?? 'Guest'; // Only null/undefined
// Optional chaining
const city = user?.address?.city; // Safe navigation
// Logical assignment
config.debug ??= false; // Assign if nullish
Troubleshooting
Common Issues
Error
Cause
Fix
ReferenceError: x is not defined
Variable not declared
Check spelling, scope
TypeError: Cannot read property
Accessing null/undefined
Use optional chaining ?.
NaN result
Invalid number operation
Validate input types
Unexpected true/false
Loose equality ==
Use strict ===
Debug Checklist
// 1. Check type
console.log(typeof variable);
// 2. Check value
console.log(JSON.stringify(variable));
// 3. Check for null/undefined
console.log(variable === null, variable === undefined);
// 4. Use debugger
debugger;
Production Patterns
Input Validation
function processNumber(value) {
if (typeof value !== 'number' || Number.isNaN(value)) {
throw new TypeError('Expected a valid number');
}
return value * 2;
}
Safe Property Access
const city = user?.address?.city ?? 'Unknown';
const callback = options.onComplete?.();