Uko ndani ya app. Fungua kwenye browser kwa muonekano na downloads bora.
FAUSTINE MWOYA November 17, 2025 1 min read

Jinsi ya Kutumia ES6 Modules kwa Organized JS Code

ES6 Modules hukuwezesha kugawanya JavaScript code kwenye files tofauti, kufanya code iwe readable, reusable na maintainable. Hii ni muhimu kwa projects kubwa.

✅ A. HTML Setup

ES6 Modules Demo

Faulink ES6 Modules Example

✅ B. Create JS Module
file: mathUtils.js
// Named export
export function add(a, b) {
return a + b;
}

export function multiply(a, b) {
return a * b;
}

✅ C. Import Module in Main JS
file: main.js
import { add, multiply } from './mathUtils.js';

const sum = add(5, 10);
const product = multiply(5, 10);

console.log('Sum:', sum); // 15
console.log('Product:', product); // 50

✅ D. Default Export Example
file: greet.js
export default function greet(name) {
return `Hello, ${name}!`;
}

file: main.js (continue)
import greet from './greet.js';

console.log(greet('Faulink')); // Hello, Faulink!

✅ Jinsi Inavyofanya Kazi

export → inatoa function, variable au class kutoka module

import → inachukua code kutoka module nyingine

type="module" → inaruhusu ES6 imports kwenye HTML

Code inakuwa organized, reusable na easy to maintain

🔗 Links Za Kujifunza Zaidi

🌐 Faulink Official Website:
https://www.faulink.com/

📘 Jifunze Web Design & Programming (Tutorials / Mifumo):
https://www.faulink.com/excel_mifumo.php

📲 WhatsApp Msaada:
https://wa.me/255693118509

🚀 Unahitaji mfumo au website ya biashara?

Chagua huduma hapa chini kisha mteja bofya moja kwa moja kwenda kwenye ukurasa wa huduma au kuwasiliana nasi kwa WhatsApp.

Share this post

Comments

0
No comments yet. Be the first to comment.

Continue Reading

Subscribe

Get new updates

Jiunge upokee posts mpya, tutorials, na updates za mifumo moja kwa moja kwenye email yako.

Quick Actions