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

    Classes and OOP · Lesson 28 of 45

    Inheritance

    A class that takes everything from another and adds more.

    8 minutes3 games

    With extends a new class inherits every property and method of another (the parent), then adds or changes things. Inside its constructor you must call super(...) first so the parent sets up its part.

    JavaScript
    class User {
      constructor(name) {
        this.name = name
      }
      describe() {
        return `${this.name} is a user`
      }
    }
    
    class Instructor extends User {
      constructor(name, subject) {
        super(name)
        this.subject = subject
      }
      describe() {
        return `${super.describe()} who teaches ${this.subject}`
      }
    }
    
    const people = [new User("Ali"), new Instructor("Sara", "JavaScript")]
    for (const p of people) console.log(p.describe())
    console.log(people[1] instanceof User)
    • User
      • name
      • describe()
      • Instructor extends User
        • subject
        • describe() (overridden)

    Important

    What happens in that loop is polymorphism: the same line, p.describe(), behaves differently depending on what p is.

    Avoid long inheritance chains (A ← B ← C ← D). Composition (an object holding other objects that do the work) is usually better.

    Interview question

    Why must you call super() before using this in a subclass constructor?

    What's the output?

    class A {
      hi() {
        return "A"
      }
    }
    class B extends A {
      hi() {
        return "B" + super.hi()
      }
    }
    console.log(new B().hi())

    What will this code print?

    Spot the bug

    One line throws an error. Which?

    Exercise

    Make Square extends Rectangle taking just side. Print new Square(6).area() (36).

    Expected output: 36

    JavaScript
    class Rectangle {
      constructor(w, h) {
        this.w = w
        this.h = h
      }
      area() {
        return this.w * this.h
      }
    }
    

    Learn more from

    • javascript.info: Class inheritancejavascript.info
    • MDN: extendsdeveloper.mozilla.org
    • javascript.info: Prototypal inheritancejavascript.info

    Played 0 of 3 games

    Sign in to save your progress and earn XP.

    PreviousClassesNextControlling the page (DOM)
    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.