🔑 Variables: let
& const
Always prefer const
for immutable variables and let
for mutable ones.
Avoid var
due to function scope and hoisting quirks.
👉 Learn more about variable declarations
📌 Destructuring Assignments
Simplify object and array extraction with destructuring:
const { name, age } = user;
const [first, second] = ['a', 'b'];
Use it to make code more readable and concise.
👉 Explore destructuring in depth
🔄 Arrow Functions
Use arrow functions for shorter syntax and lexical this
:
const add = (a, b) => a + b;
Avoid using function
keywords when possible.
👉 Arrow functions explained
🧱 Modules & Imports
Organize code with ES6 modules:
import { fetchData } from './api';
Always use import
instead of require
for modern projects.
👉 Module system guide
📦 Default Parameters
Set default values for function parameters:
function greet(name = 'Guest') { console.log(name); }
Improves code flexibility and reduces null checks.
👉 Function parameters tutorial