Template literals are string literals that allow embedded expressions, multi-line strings, and easier string construction.
`) instead of quotes
Default function parameters let you set a fallback value for a function’s arguments if no value
(or undefined) is passed. Introduced in ES6 (2015), this feature makes functions safer
and cleaner by avoiding errors when arguments are missing.
Explanation:
If no argument is passed → name defaults to "Guest".
If "Alice" is passed → it overrides the default.
Imagine ordering pizza 🍕:
If you don’t specify toppings, the shop gives you “cheese” by default.
If you say "pepperoni", they override the default.
if (param === undefined) checks).👉 ES6 default parameters make this much simpler.
Destructuring is an ES6 feature that allows you to unpack values from arrays or objects
into distinct variables in a clean and concise way. Instead of accessing values with indexes
(arr[0]) or dot notation (obj.key), destructuring lets you
extract them directly into variables.
undefined or null.
The three dots (...) in JavaScript can act in two different ways depending on context:
👉 Same syntax, different purpose depending on where it’s used.
Think of ... like a bag of candies 🍬:
Spread → You pour out the candies one by one (expand).
Rest → You scoop up multiple candies into a bag (gather).
...args).... in big objects/arrays may impact performance.
Modules in JavaScript allow you to split your code into separate files and reuse them across projects.
Introduced in ES6 (2015), they make code more organized, reusable, and maintainable.
Works using export (to share code) and import (to use code).
export in one file, import in another.{} required.{}.type="module" in HTML when used in browsers.
Think of modules like a restaurant kitchen 🍴:
The chef (export) prepares dishes.
The waiter (import) brings only what’s ordered.
"type": "module" in package.json for Node.js ES modules.