Created
July 3, 2022 19:10
-
-
Save batazo/ccc9c990a90ce6776e123af1b9f081e8 to your computer and use it in GitHub Desktop.
Revisions
-
batazo renamed this gist
Jul 3, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
batazo created this gist
Jul 3, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ class Banner extends HTMLElement { // Private variable that cannot be reached directly from outside, but can be modified by the methods inside: #slogan = "Hello there!" #counter = 0 // private getters and setters (accessors): get #slogan() {return #slogan.toUpperCase()} set #slogan(text) {this.#slogan = text.trim()} get #counter() {return #counter} set #counter(value) {this.#counter = value} constructor() { super(); this.onmouseover = this.#mouseover.bind(this); } // private method: #mouseover() { this.#counter = this.#counter++; this.#slogan = `Hello there! You've been here ${this.#counter} times.` } }