<my-ce></my-ce>

<script>
  class MyCe extends HTMLElement {
    constructor() {
      super()
      this.textContent = 'Hello, World!'
    }
  }
  customElements.define('my-ce', MyCe)
</script>

Define constructor method

The constructor method is called when a new instance of the custom element is created. This is where you can set up the initial state of the custom element.