Master JavaScript Programming From Scratch

Clear, interactive, and structured JavaScript lessons designed for absolute beginners.

Modern JavaScript

Modern JavaScript provides cleaner, shorter and more powerful ways to write JavaScript programs.

What is Modern JavaScript?

Modern JavaScript refers to the newer features introduced in JavaScript to make code easier to read, maintain and develop.

These features include let, const, template literals, arrow functions, spread and rest operators, destructuring and modules.

Simple Definition

Modern JavaScript means using newer JavaScript features and syntax to write clean, readable and maintainable code.

Modern JavaScript

Modern JavaScript helps developers write cleaner and more efficient code.

Modern JavaScript Features
Modern JavaScript
→
let / const
→
Template Literals
→
Spread / Rest

Example 1: let and const

Modern JavaScript provides let and const for declaring variables.

let name = "Rahul";
const course = "JavaScript";

console.log("Name:", name);
console.log("Course:", course);
Name: Rahul
Course: JavaScript

Example 2: Template Literals

Template literals allow us to create strings using backticks and easily insert variables using ${}.

let name = "Rahul";
let course = "JavaScript";

let message = `Welcome ${name} to ${course}`;

console.log(message);
Welcome Rahul to JavaScript

Example 3: Arrow Function

Arrow functions provide a shorter syntax for writing functions.

const add = (a, b) => {
    return a + b;
};

console.log("Result:", add(10, 20));
Result: 30

Example 4: Spread Operator

The spread operator ... can be used to expand elements of an array.

let numbers1 = [10, 20];
let numbers2 = [30, 40];

let numbers = [...numbers1, ...numbers2];

console.log(numbers);
[10, 20, 30, 40]

Example 5: Destructuring

Destructuring allows us to extract values from arrays or objects into separate variables.

const student = {
    name: "Amit",
    age: 22
};

const { name, age } = student;

console.log("Name:", name);
console.log("Age:", age);
Name: Amit
Age: 22

Why Use Modern JavaScript?

✔ Cleaner code

✔ Shorter syntax

✔ Better readability

✔ Easier maintenance

✔ Useful for modern web applications

Summary

Modern JavaScript introduces powerful features that make JavaScript development easier and more efficient. Important features include let and const, template literals, arrow functions, spread operators and destructuring.