Create an instance and call a method on it.

Class Instances

class_instance.js
const name = "Ada";
class Badge {
  constructor(name) {
    this.name = name;
  }

  label() {
    return this.name + ":ok";
  }
}

const label = new Badge(name).label();

console.log("name=" + name);
console.log("label=" + label);
class-instance A class describes objects with shared behavior. `new` creates an instance, and methods read the instance fields through `this`.