Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd593fc2

Browse files
authored
private class methods and fields
1 parentaf8ebc2 commitd593fc2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

‎README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
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+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp