Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 566 Bytes

classes.md

File metadata and controls

18 lines (15 loc) · 566 Bytes

Classes

Classes are a new feature in ES6, used to describe the blueprint of an object and make EcmaScript's prototypical inheritance model function more like a traditional class-based language.

class Hamburger {
  constructor() {
    // This is the constructor.
  }
  listToppings() {
    // This is a method.
  }
}

Traditional class-based languages often reserve the word this to reference the current (runtime) instance of the class. This is also true in JavaScript, but JavaScript code can optionally supply this to a method at call time.