File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 3333| 27 | [ Check if a node is in the viewport] ( #Check-if-a-node-is-in-the-viewport ) |
3434| 28 | [ Notify when element size is changed] ( #Notify-when-element-size-is-changed ) |
3535| 29 | [ Detect if Browser Tab is in the view] ( #Detect-if-Browser-Tab-is-in-the-view ) |
36+ | 30 | [ Private class methods and fields] ( #Private-class-methods-and-fields ) |
3637
3738
3839
@@ -614,3 +615,33 @@ document.addEventListener("visibilitychange", onVisibilitychange)
614615` ` `
615616
616617
618+ **[⬆ Back to Top](#table-of-contents)**
619+ ### Private class methods and fields
620+
621+ class Students {
622+ #name;
623+
624+ constructor(){
625+ this.#name = "JS snippets";
626+ }
627+
628+ #privateMethod() {
629+ return 'Come and learn Js with us';
630+ }
631+
632+ getPrivateMessage() {
633+ return this.#privateMethod();
634+ }
635+ }
636+
637+ const instance = new Something();
638+ console.log(instance.name); //=> undefined
639+ console.log(instance.privateMethod); //=> undefined
640+ console.log(instance.getPrivateMessage()); //=> Come and learn Js with us
641+
642+ ` ` `
643+
644+
645+
646+
647+
You can’t perform that action at this time.
0 commit comments