Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1918 from hamishwillee/class-static
Add class static initialization block example
- Loading branch information
Showing
3 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
js/lib/* | ||
js/mode/* | ||
|
||
# js class static blocks is cuurently ignored as it fails test | ||
live-examples/js-examples/classes/classes-static-initialization.js |
12 changes: 12 additions & 0 deletions
12
live-examples/js-examples/classes/classes-static-initialization.js
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class ClassWithStaticInitializationBlock { | ||
static staticProperty1 = "Property 1"; | ||
static staticProperty2; | ||
static { | ||
this.staticProperty2 = "Property 2" | ||
} | ||
} | ||
|
||
console.log(ClassWithStaticInitializationBlock.staticProperty1); | ||
// output: "Property 1" | ||
console.log(ClassWithStaticInitializationBlock.staticProperty2); | ||
// output: "Property 2" |
This file contains 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 characters