React relies heavily on modern JavaScript (ES6+). Mastering these concepts will make writing React intuitive and clean.
1. Destructuring Arrays & Objects
// Array destructuring (used by useState):
const [count, setCount] = useState(0);
// Object destructuring (used by props):
function Profile({ name, role, department }) {
return <p>{name} works as {role} in {department}.</p>;
}
2. The Spread Operator (...)
const defaultSettings = { theme: "light", notifications: true };
const userSettings = { ...defaultSettings, theme: "dark" };