Loading content…
Loading content…
JavaScript powers interactivity on the web. Understanding its core concepts is essential before moving to frameworks like React.
// Modern variable declaration
const name = "Alice"; // Use const by default
let age = 25; // Use let if reassignment needed
var old = true; // Avoid var (function-scoped, confusing)
// Types
const number = 42;
const string = "hello";
const boolean = true;
const array = [1, 2, 3];
const object = { name: "Alice", age: 25 };
const nothing = null;
const undefined_value = undefined;
Senior Developer Wisdom
const by default. Use let only when you need reassignment. var is legacy and causes scope confusion.// Arrow functions (modern)
const add = (a, b) => a + b;
// Traditional function
function multiply(a, b) {
return a * b;
}
// Functions with default parameters
const greet = (name = "Guest") => `Hello, ${name}`;
// Array methods
const numbers = [1, 2, 3, 4, 5];
numbers.map(n => n * 2); // Transform
numbers.filter(n => n > 2); // Filter
numbers.find(n => n === 3); // Find first
// Object destructuring
const person = { name: "Alice", age: 25 };
const { name, age } = person;
Common Pitfall
// Promises
const fetchData = () => {
return fetch("/api/data")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
};
// Async/await (modern, cleaner)
const getData = async () => {
try {
const response = await fetch("/api/data");
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
};
const and let, never varJavaScript Fundamentals Checklist
Marking it complete updates your roadmap progress percentage.