Clean β’ Professional
JavaScript has evolved over the years through ECMAScript (ES) standards, which define the languageβs syntax, features, and behavior. Each version introduced new capabilities, improved performance, and enhanced error handling.

The first official ECMAScript version.
try-catch support using the Error object.Example:
try {
throw new Error("An error occurred");
} catch (e) {
console.log(e.message); // Output: An error occurred
}
TypeError and ReferenceError.finally block for cleanup after try-catch.Example:
try {
let x = y; // y is undefined
} catch (e) {
console.log(e.name); // ReferenceError
} finally {
console.log("Cleanup done");
}
forEach.error.stack and better reporting of undeclared variables.Example:
"use strict";
try {
undeclaredVar = 5; // ReferenceError in strict mode
} catch (e) {
console.log(e.stack);
}
Major overhaul introducing let/const, arrow functions, classes, modules, template literals, Promises, Map/Set, and Symbols.
Error handling:
.catch() for async error handlingExample:
class CustomError extends Error {
constructor(message) {
super(message);
this.name = "CustomError";
}
}
const promise = Promise.reject(new CustomError("Failed"));
promise.catch(e => console.log(e.name, e.message)); // CustomError Failed
*).Example:
let arr = [1, 2, 3];
console.log(arr.includes(2)); // true
console.log(2 ** 3); // 8
try-catch.Example:
async function fetchData() {
try {
const response = await fetch("<https://invalid-url>");
} catch (e) {
console.error("Fetch error:", e.message);
}
}
for await...of with proper try-catch.Example:
async function processAsync(iterable) {
try {
for await (let item of iterable) {
console.log(item);
}
} catch (e) {
console.error(e);
}
}
catch { } without specifying the error.Example:
try {
JSON.parse("invalid");
} catch {
console.log("Parsing failed"); // No error variable needed
}
?.), nullish coalescing (??), and Promise.allSettled().Example:
let obj;
console.log(obj?.property); // undefined
Example:
let text = "foo bar foo";
console.log(text.replaceAll("foo", "baz")); // baz bar baz
Error.cause allows linking errors to their root cause.Example:
try {
throw new Error("Outer error", { cause: new Error("Inner error") });
} catch (e) {
console.log(e.message); // Outer error
console.log(e.cause.message); // Inner error
}