# ES6 Inheritance

Other languages, such as C++ and Java, handle inheritance in a different way. Most OOP languages follow a **class** pattern, which contains the constructor and any methods shared across objects, as opposed to attaching methods to the prototype.

ES6, short for ECMAScript 6, is the latest update coming to JavaScript. ES6 provides a different way for implementing constructors and inheritance. An example is shown below. See resources such as [this one](http://javascriptplayground.com/blog/2014/07/introduction-to-es6-classes-tutorial/) for more details.

```javascript
class Person {
  constructor(name) {
    this.name = name;
  }

  greet() {
    return "Hello, my name is " + this.name;
  }
}

class Student extends Person {
  constructor(name, course) {
    super(name);
    this.course = course;
  }
}
```

Note that the parent/superclass constructor is called using the `super` keyword. Also, since ES6 isn't implemented across all platforms, this code won't work in many browsers. In order to write ES6 code now while still supporting older systems, we can use [Babel](https://babeljs.io/) to compile this code into ES5-friendly code.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://romebell.gitbook.io/sei-412/javascript/01readme-2/04es6classes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
