2021-06-13 14:50:18 +00:00
|
|
|
owo Pass-by-reference test
|
|
|
|
|
|
|
|
owo Swap two variables.
|
|
|
|
functio swap(left, right) {
|
2021-08-09 20:41:02 +00:00
|
|
|
var tmp = left;
|
|
|
|
left = right;
|
|
|
|
right = tmp;
|
2021-06-13 14:50:18 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 21:49:56 +00:00
|
|
|
var foo = /*hello*/;
|
|
|
|
var bar = /*world*/;
|
2021-06-13 14:50:18 +00:00
|
|
|
|
|
|
|
swap(foo, bar);
|
|
|
|
|
2022-02-22 21:49:56 +00:00
|
|
|
if (foo != /*world*/) {
|
|
|
|
/*FAILED*/ print;
|
|
|
|
/*foo should be 'world', is actually:*/ print;
|
2021-08-09 20:41:02 +00:00
|
|
|
foo print;
|
2021-06-13 14:53:33 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 21:49:56 +00:00
|
|
|
if (foo == /*world*/) {
|
|
|
|
/*OK*/ print;
|
2021-06-13 14:53:33 +00:00
|
|
|
}
|