Tutorials Modern JavaScript (ES6+) for Beginners
Modules — import/export & What to Learn Next
Learn Modules — import/export & What to Learn Next in our free Modern JavaScript (ES6+) for Beginners series. Step-by-step explanations, examples, and interview tips on Toolliyo Academy.
On this page
Modules — import/export & What to Learn Next
ES6 modules split code into files with explicit import and export. React, Vue, and modern Node.js all use this system. This is the last core ES6+ topic before you teach Node or React.
Named exports
// utils/math.js
export function add(a, b) { return a + b; }
export const TAX_RATE = 0.18;
// checkout.js
import { add, TAX_RATE } from './utils/math.js';
const total = add(100, 100 * TAX_RATE);
Default export
// services/api.js
export default async function fetchCourses() {
const res = await fetch('/api/courses');
return res.json();
}
// app.js
import fetchCourses from './services/api.js';
Re-export & import all
import * as MathUtils from './utils/math.js';
MathUtils.add(2, 3);
// format.js
export function formatPrice(inr) {
return `₹${inr.toLocaleString('en-IN')}`;
}
// catalog.js
import { formatPrice } from './format.js';
export function showEbook(ebook) {
return `${ebook.title} — ${formatPrice(ebook.price)}`;
}Bonus — modern syntax you will see
// Optional chaining — safe deep access
const city = user?.address?.city;
// Nullish coalescing — default only for null/undefined
const theme = settings.theme ?? 'dark';
// Logical assignment
user.role ||= 'student';
What to learn next on Toolliyo
- Review this course — practice each lesson in console
- Build a Real-Time Chat App with Node.js — uses async, modules, arrow functions
- Node.js Tutorial — full backend path
- React Tutorial — components + hooks (needs ES6 first)
Course recap checklist
- ✅
let/constand block scope - ✅ Arrow functions and array methods
- ✅ Template literals, destructuring, spread/rest
- ✅ Promises and async/await
- ✅ import / export modules
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!