Code

General Code

Creating a Module

In JavaScript, we can use modules to organize our classes so our code is more manageable. We can put as many classes as we want into a module. Each module is its own JavaScript file. Typically, the functionality related to that module is put into the file and organized accordingly…in classes, objects, etc. Imagine if […]

Creating a Module Read More »

Inheritance

In OO languages, we want to stay DRY and avoid getting WET. Inheritance allows us to avoid writing duplicate code. JavaScript classes give us this ability… We can use this animal class and extend (inherit) it to another object. Here’s an example… The output would be “Bongo”. We extended the Animal class. This gives us

Inheritance Read More »

Methods

In JavaScript, methods are function that exist on an object. Here is an example… This code would output Bongo says “ugh!”. Notice that we did not use the function keyword. We did need the return though. Note: You might notice that we used backticks in this example. You also might notice something odd. We used

Methods Read More »