Git Product home page Git Product logo

fewpjs-class-extensions-super-lab's Introduction

JavaScript Class Extension Lab: super

Learning Goals

  • Practice using super to extend child class functionality

Introduction

In this lab we're going to practice the two most common usages of the super keyword.

Instructions

  1. Define a Tree class that will act as our parent.

    • A Tree instance should take in one parameter when created, species, and assign this to a property named species.
    • A Tree should have a static method, definition(), that returns a short definition of all trees.

    A tree is a perennial plant with an elongated stem, or trunk, supporting branches and leaves.

  2. Define a Deciduous class that extends Tree

    • A Deciduous instance takes two parameters, species and name. Use super() in the constructor to use the parent class constructor to assign species. After super(), assign the name parameter to the a name property in the Deciduous constructor
    • Create a static method, definition(), that uses super to access definition() from Tree and add the following to the provide a specific definition for Deciduous:

    Deciduous trees shed their leaves annually.

  3. Define a Evergreen class that extends Tree

    • An Evergreen instance takes two parameters, species and name. Use super() in the constructor to use the parent class constructor to assign species, then assign name to a property in the Evergreen constructor
    • Create a static method, definition(), that uses super to access definition() from Tree and add the following to the provide a specific definition for Evergreen:

    Evergreens keep their leaves all year round.

Resources

fewpjs-class-extensions-super-lab's People

Contributors

dependabot[bot] avatar drakeltheryuujin avatar ihollander avatar lizbur10 avatar maxwellbenton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.