Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4499726
test_return.cjs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
682 B
Referenced Files
None
Subscribers
None
test_return.cjs
View Options
// Test return in class methods
class Test {
method1(x) {
console.log("Method1: x =", x);
if (x > 5) {
console.log("Returning early");
return;
}
console.log("After if block");
}
method2(x) {
console.log("Method2: x =", x);
if (x > 5) {
console.log("Returning early with value");
return "early";
}
console.log("After if block");
return "normal";
}
}
let t = new Test();
console.log("Test 1:");
t.method1(3);
console.log("\nTest 2:");
t.method1(7);
console.log("\nTest 3:");
let r1 = t.method2(3);
console.log("Returned:", r1);
console.log("\nTest 4:");
let r2 = t.method2(7);
console.log("Returned:", r2);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 3, 8:07 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
523977
Default Alt Text
test_return.cjs (682 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment