Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    JSJavaScript

    Getting started

    • What is JavaScript?
    • Variables: let, const and var
    • Data types
    • Type conversion

    Operators and strings

    • Arithmetic and assignment
    • Comparison and logic
    • Strings and template literals
    • String methods
    • Numbers and Math

    Control flow

    • Conditions: if and else
    • switch and the ternary operator
    • Loops: for and while
    • Challenge: FizzBuzz

    Functions

    • Functions
    • Arrow functions
    • Parameters: default, rest and spread
    • Scope and closures
    • Callbacks and higher-order functions

    Arrays

    • Array basics
    • map, filter and find
    • reduce and sorting
    • Destructuring

    Objects

    • Object basics
    • Copies and references
    • Methods and this
    • JSON and optional chaining

    Classes and OOP

    • Classes
    • Inheritance

    JavaScript in the page

    • Controlling the page (DOM)
    • Creating elements
    • Events
    • Forms and validation
    • Saving in the browser (localStorage)

    Errors and async

    • Handling errors: try and catch
    • Timers and the event loop
    • Promises
    • async and await
    • Fetching data from an API

    Practical tools and techniques

    • Searching with regular expressions
    • Cancellation and stale results
    • Testing and debugging JavaScript

    Modern JavaScript and a project

    • Map and Set
    • Dates and localised formatting
    • Modules: import and export
    • Project: a complete to-do app
    JavaScript

    Modern JavaScript and a project · Lesson 44 of 45

    Modules: import and export

    Split code into small files, each doing one job.

    7 minutes2 games

    Real projects split code across files. Each file is a module that exports what others may use, and other files import it. There are named exports (many per file) and one default export.

    JavaScript
    // math.js
    export const PI = 3.14159
    export function area(r) {
      return PI * r * r
    }
    export default function greet(name) {
      return `Hi ${name}`
    }
    
    // app.js
    import greet, { area, PI } from "./math.js"
    import * as MathTools from "./math.js"
    
    console.log(greet("Ali"), area(2), MathTools.PI)
    HTML
    <!-- in the browser, mark the script as a module -->
    <script type="module" src="app.js"></script>

    math.js: export

    app.js: import

    tools like Vite bundle them for the site

    Important

    Each module has its own scope: nothing inside leaks out except what's exported. That prevents name clashes.

    Interview question

    What's the difference between a named and a default export?

    Complete the code

    Import the sum function from ./utils.js.

     { sum }  "./utils.js"

    Quick question

    What does import greet from "./math.js" bring in?

    Learn more from

    • javascript.info: Modules, introductionjavascript.info
    • MDN: JavaScript modulesdeveloper.mozilla.org

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousDates and localised formattingNextProject: a complete to-do app
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.