Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Inheritance #75

@jmamor

Description

@jmamor

I'm quite new to the javascript universe and I was trying to use inheritance in a sample project I have created with six. Everything compiles fine but I can't reach the properties defined in the base class. I've followed the ES-Harmony syntax with no results.

I'll post an example just you understand what I mean:

I have 2 files, Car.six and Garage.six:

In Car.six:

class Vehicle
{   
    constructor(color, year, numberPlate)
    {   
        this.year = year;
        this.numberPlate = numberPlate
        this.color = carcolor
    }   
}


class Car extends Vehicle{
  constructor(model, color, year, numberPlate){
    super(color, year, numberPlate);
    this.model = model;
  }
}

export Car;
export Vehicle;

And in Garage.six:

function print(message)
 {
   console.log(message);
 }

module cars = "./CarManager/car"

var myCar = new cars.Car("ford focus", "red", "2006", "8907JJK");
print(myCar.model);
print(myCar.color);

While

print(myCar.model); 

displays "ford focus" as expected,

print(myCar.color);

prints "undefined", as it can't reach the color property defined in the Vehicle class.

I've also tried the get property approach inside the Vehicle class with no results:

get color() { return (this).color };

As well I have tried to set the color property as public, but a compiler error is thrown:
Use of future reserved word in strict mode

Is that an issue or I'm doing something wrong?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions