> For the complete documentation index, see [llms.txt](https://deemolover.gitbook.io/log-os/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://deemolover.gitbook.io/log-os/programming-languages/javascript/class.md).

# Class

ES6 引入了 class 语法，提供了关于类构造、继承、静态成员的语法糖。

```javascript
// define a class 
class Car {
  // constructor method
  constructor(name, year) {
    this.name = name;
    this.year = year;
  }

  // other methods
  run() {
   // ...
  }
}

// create new instance
let myCar1 = new Car("Ford", 2014);
```

## Static

{% embed url="<https://javascript.info/static-properties-methods>" %}

## Reference

\[1] <https://www.w3schools.com/js/js_class_intro.asp>
