This file is the practical ES6+ revision sheet: syntax, patterns, and APIs that modern JavaScript code uses every day.
Modern JavaScript improves readability, safer scoping, and better composition. Interviewers expect you to be comfortable with these features, not just recognize them.
letis block-scoped and reassignable.constis block-scoped and cannot be rebound.varis function-scoped and should be treated as legacy in modern code.
- Shorter syntax
- Lexical
this - Good for callbacks
- Not suitable when you need dynamic
this
const user = { name: "Ada", age: 28 };
const { name, age } = user;
const point = [10, 20];
const [x, y] = point;const numbers = [1, 2, 3];
const copy = [...numbers];
function sum(...values) {
return values.reduce((total, value) => total + value, 0);
}const name = "Ada";
const message = `Hello, ${name}`;function greet(name = "Guest") {
return `Hello, ${name}`;
}exportandimportare standard module syntax.- Named exports and default exports solve different needs.
- Modules improve dependency clarity.
Know when and why to use:
mapfilterreducefindsomeeveryflatMap
Mapfor key-value storage where keys are not limited to strings.Setfor uniqueness.
const city = user?.address?.city ?? "Unknown";Do not confuse ?? with ||. ?? only falls back on null or undefined.
Symbolcreates unique identifiers.- Iterators define how values are produced one by one.
- Generators pause and resume execution with
yield.
These appear less often in everyday frontend work, but still come up in deeper language interviews.
It prevents rebinding and makes intent clearer.
When you need a dynamic this, such as certain object methods or constructor-like behavior.
When you need non-string keys, predictable iteration, or dedicated key-value semantics.