Enterprise Verified
Academy Frontend Web Development REACT React ES6 Essentials
Advertisement
Google AdSense Slot (LEADERBOARD)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Prerequisites 8 min read • Chapter 5 of 26

React ES6 Essentials

Master essential ES6 features used in React: arrow functions, array destructuring, object destructuring, spread operator, and the .map() method.

React relies heavily on modern JavaScript (ES6+). Mastering these concepts will make writing React intuitive and clean.

1. Destructuring Arrays & Objects

// Array destructuring (used by useState):
const [count, setCount] = useState(0);

// Object destructuring (used by props):
function Profile({ name, role, department }) {
  return <p>{name} works as {role} in {department}.</p>;
}

2. The Spread Operator (...)

const defaultSettings = { theme: "light", notifications: true };
const userSettings = { ...defaultSettings, theme: "dark" };

Example

<!DOCTYPE html>
<html>
<body style="font-family:monospace;padding:20px;background:#f8fafc;">
    <h3>ES6 Features in React</h3>
    <pre id="output"></pre>
    <script>
        const tools = ["In-Hand Salary", "GST Calculator", "SIP Planner"];
        const [primary, ...rest] = tools;
        document.getElementById("output").innerText = 
            `Primary Tool: ${primary}\nRemaining Suite: ${rest.join(", ")}`;
    </script>
</body>
</html>
Try it Yourself >> Opens live sandboxed code editor
Advertisement
Google AdSense Slot (IN-ARTICLE)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php

Community Q&A & Discussion

No questions yet. Be the first to start the discussion!
Enterprise Operations Suite

Streamline Employee Payroll & Attendance Operations

Eliminate manual spreadsheet errors. Integrate automated attendance tracking, EPF/ESI statutory calculations, and custom GST invoices.

Copied!

AI Learning Assistant

Ready to explain & guide

Hello! I am your MBS Digital AI Tutor. Ask me to explain concepts, review code, or suggest debugging steps.

Quick Starters:
AI Tutor is thinking...