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.

results matching ""

    No results matching ""