Learn JavaScript: Classes

Learn how to create classes and use inheritance to minimize redundancy in your code.

Start[missing "en.views.course_landing_page.introduction-to-javascript.course_illustration" translation]
Classes
Lesson 1 of 1
  1. 1

    JavaScript is an object-oriented programming (OOP) language we can use to model real-world items. In this lesson, you will learn how to make classes. Classes are a tool that developers use to q...

  2. 2

    In the last exercise, you created a class called [...] , and used it to produce a [...] object. Although you may see similarities between class and object syntax, there is one important method...

  3. 3

    Now, we're ready to create class instances. An instance is an object that contains the property names and methods of a class, but with unique property values. Let's look at our [...] class exam...

  4. 4

    At this point, we have a [...] class that spins up objects with [...] and [...] properties. Below, we will add getters and a method to bring our class to life. Class method and getter synta...

  5. 5

    Finally, let's use our new methods to access and manipulate data from [...] instances. [...] In the example above, we create the [...] class, then create an instance, and save it to a variab...

  6. 6

    Imagine our doggy daycare is so successful that we decide to expand the business and open a kitty daycare. Before the daycare opens, we need to create a [...] class so we can quickly generate [...

  7. 7

    In the last exercise, we created a parent class named [...] for two child classes named [...] and [...] . The [...] class below contains the shared properties and methods of [...] and [...

  8. 8

    We've abstracted the shared properties and methods of our [...] and [...] classes into a parent class called [...] (See below). [...] Now that we have these shared properties and methods ...

  9. 9

    Now that we know how to create an object that inherits properties from a parent class let's turn our attention to methods. When we call [...] in a class declaration, all of the parent methods ar...

  10. 10

    In addition to the inherited features, child classes can contain their own properties, getters, setters, and methods. Below, we will add a [...] getter. The syntax for creating getters, setters...

  11. 11

    Sometimes you will want a class to have methods that aren't available in individual instances, but that you can call directly from the class. Take the [...] class, for example — you can b...

  12. 12

    Way to go! Let's review what you learned. - Classes are templates for objects. - Javascript calls a constructor method when we create a new instance of a class. - Inheritance is when we cre...

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo

Learn JavaScript: Classes

Start[missing "en.views.course_landing_page.introduction-to-javascript.course_illustration" translation]