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 42 of 45

    Map and Set

    Keys of any type, and lists without duplicates.

    7 minutes2 games
    • Set is a list where nothing repeats: add, has, delete, size.
    • Map is like an object whose keys can be any type (numbers, objects…), keeps insertion order and has size: set, get, has.
    JavaScript
    const tags = new Set(["js", "css", "js", "html", "css"])
    console.log(tags.size, tags.has("js"))
    console.log([...tags])
    
    const visits = new Map()
    visits.set("/home", 3)
    visits.set("/courses", 7)
    visits.set("/home", visits.get("/home") + 1)
    console.log(visits.get("/home"), visits.size)
    for (const [page, n] of visits) console.log(page, n)
    ObjectMap

    Key types

    strings (and symbols)

    any type

    Size

    Object.keys(o).length

    map.size

    Frequent add/delete

    fine

    faster

    JSON-friendly?

    yes

    not directly

    Important

    Set.has stays fast even with thousands of items, much faster than array.includes, which scans one by one. If you often ask “is it there?”, use a Set.

    Interview question

    How do you efficiently find the common items of two arrays?

    What's the output?

    const s = new Set([1, 2, 2, 3, 3, 3])
    console.log(s.size)

    What will this code print?

    Exercise

    Print how many different students submitted (3).

    Expected output: 3

    JavaScript
    const submissions = ["ali", "mona", "ali", "omar", "mona"]
    

    Learn more from

    • javascript.info: Map and Setjavascript.info
    • MDN: Mapdeveloper.mozilla.org
    • MDN: Setdeveloper.mozilla.org

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousTesting and debugging JavaScriptNextDates and localised formatting
    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.