> For the complete documentation index, see [llms.txt](https://hemantajax-2.gitbook.io/es6-step-by-step/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hemantajax-2.gitbook.io/es6-step-by-step/class.md).

# Class

```javascript
class Car{
    constructor(name, wheels){
        this.name = name;
        this.wheels = wheels;
    }

    showDetail(){
        console.log(`${this.name} have ${this.wheels} wheels`);
    }
}

var c = new Car("BMW", 4);
c.showDetail(); // BMW have 4 wheels
```

## Class Inheritance

```javascript
class Car{
    constructor(name, wheels){
        this.name = name;
        this.wheels = wheels;
    }

    showDetail(){
        console.log(`${this.name} have ${this.wheels} wheels`);
    }
}

var c = new Car("BMW", 4);
c.showDetail(); // BMW have 4 wheels

class Maruti extends Car{

    constructor(){        
        super("Maruti", 4);
        this.cost = "cheap";
        super().showDetail();
    }

    showDetail(){
        console.log(`${this.name} have ${this.wheels} wheels and it's super ${this.cost}`);
    }
}

var m = new Maruti();
m.showDetail(); // Maruti have 4 wheels and it's super cheap
```
