-
-
Save jridgewell/c59e6ff1a3f7700ec26b0ca322643ea2 to your computer and use it in GitHub Desktop.
Revisions
-
jridgewell revised this gist
Feb 20, 2018 . 1 changed file with 11 additions and 0 deletions.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,11 @@ function create() { return { private #data: '', add(str) { this.#data += str; }, toString() { return this.#data; }, }; } -
rauschma revised this gist
Feb 13, 2018 . 1 changed file with 4 additions and 0 deletions.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 @@ -1,5 +1,9 @@ # Fields with arbitrarily scoped privacy Info on private fields: http://2ality.com/2017/07/class-fields.html ## Q&A * Why the prefix `#`? * You define keys and these keys additionally work completely differently from property keys. * Is the keyword `private` necessary? -
rauschma revised this gist
Feb 13, 2018 . 1 changed file with 2 additions and 0 deletions.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 @@ -1,6 +1,8 @@ // Can only be used within this scope private #data; class StringBuilder { // Accessible within this scope #data = ''; add(str) { this.#data += str; -
rauschma revised this gist
Feb 13, 2018 . No changes.There are no files selected for viewing
-
rauschma revised this gist
Feb 13, 2018 . 1 changed file with 2 additions and 0 deletions.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 @@ -1,3 +1,5 @@ # Fields with arbitrarily scoped privacy * Why the prefix `#`? * You define keys and these keys additionally work completely differently from property keys. * Is the keyword `private` necessary? -
rauschma revised this gist
Feb 13, 2018 . 1 changed file with 1 addition and 1 deletion.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 @@ -1,4 +1,4 @@ * Why the prefix `#`? * You define keys and these keys additionally work completely differently from property keys. * Is the keyword `private` necessary? * It could be omitted (first mention declares), but I like the distinction between declaration and mention. -
rauschma renamed this gist
Feb 13, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
rauschma created this gist
Feb 13, 2018 .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,12 @@ private #data; class StringBuilder { #data = ''; add(str) { this.#data += str; } } function toString(sb) { return this.#data; } 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,4 @@ * Why the prefix `#`? * You define keys and these keys additionally work completely differently from property keys. * Is the keyword `private` necessary? * It could be omitted, but I like the distinction between declaration and mention. 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,15 @@ // Can only be used within this scope private #data; function create() { return { // Only accessible within this scope #data: '', }; } function add(sb, str) { sb.#data += str; } function toString(sb) { return sb.#data; } 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,9 @@ class StringBuilder { private #data = ''; add(str) { this.#data += str; } toString() { return this.#data; } }