How to do it...

  1. Open your command line application and navigate to your workspace.
  2. Create a new folder named 08-02-additional-constructor-args.
  1. Create a main.js file that defines a new class named Rocket that takes a constructor argument name and assigns it to an instance property:
// main.js 
class Rocket { 
  constructor(name) { 
    this.name = name; 
  } 
} 
  1. Create a class named InactiveRocket that extends the Rocket class, and assigns an additional lastFlown property in the constructor:
// main.js 
class InactiveRocket extends Rocket { 
  constructor(name, lastFlown) { 
    super(name); 
    this.lastFlown = lastFlown; 
  } 
} 
  1. Create a main function that creates instances of both classes and logs out their names, and the lastFlown property of the InactiveRocket:
// main.js 
export function main() { 
  const saturnV = new InactiveRocket('Saturn V', new Date('May 
14,1973')); const falconHeavy = new Rocket('Falcon Heavy'); console.log(falconHeavy.name + ' is a Rocket'); console.log(saturnV.name + ' is an inactive rocket'); console.log(`${saturnV.name} was last flown:
${rocket.lastFlown}`); }
  1. Start your Python web server and open the following link in your browser:
    http://localhost:8000/.
  1. You should see output like the following:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.125.123