Skip to content

Commit 990ccc2

Browse files
authored
Create 9.3StaticBlockAndStaticProperty.js
1 parent fd1a0a5 commit 990ccc2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class config{
2+
//static property
3+
static a1={
4+
1:'hello'
5+
}
6+
//static block
7+
static{
8+
console.log("INITIALIZED");
9+
}
10+
}
11+
console.log(config.a1);
12+
console.log(config.a1);
13+
console.log(config.a1);
14+
//Summary: Static block is called only once when static method or properties are called or accessed.
15+
//OUTPUT
16+
// INITIALIZED
17+
// { '1': 'hello' }
18+
// { '1': 'hello' }
19+
// { '1': 'hello' }

0 commit comments

Comments
 (0)