Skip to content

Commit 79ec23a

Browse files
committed
Change js testcode
1 parent 531db1d commit 79ec23a

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

test_code/javascript_node/index.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
1-
function add(a, b) {
2-
return a + b;
1+
class Parent {
2+
constructor() {
3+
this.name = "Parent";
4+
}
5+
6+
callChild() {
7+
const child = new Child();
8+
child.callGrandchild();
9+
}
10+
}
11+
12+
class Child extends Parent {
13+
constructor() {
14+
super();
15+
this.name = "Child";
16+
}
17+
18+
callGrandchild() {
19+
const grandchild = new Grandchild();
20+
grandchild.printStackTrace();
21+
}
322
}
423

5-
const greeting = "Hello, world!";
6-
console.log(greeting);
24+
class Grandchild extends Child {
25+
constructor() {
26+
super();
27+
this.name = "Grandchild";
28+
}
729

8-
const number = 42;
9-
console.log("The number is:", number);
30+
printStackTrace() {
31+
console.trace(`Stack trace for ${this.name}`);
32+
}
33+
}
34+
35+
const obj = new Parent();
36+
obj.callChild();
37+
38+
function showAllStackTraces() {
39+
const grandchild = new Grandchild();
40+
grandchild.printStackTrace();
41+
}
1042

11-
const result = add(5, 3);
12-
console.log("The sum is:", result);
43+
showAllStackTraces();

0 commit comments

Comments
 (0)