Skip to content

What a function can change

Watch it run · 1 of 3

Try to change both

1function tryToChange(x, arr) {
2 x = 99;
3 arr[0] = 99;
4}
5
6let n = 5;
7const box = [5];
8tryToChange(n, box);
9console.log(n, box[0]);

Memory

number n

5

Output

(nothing yet)

line 6n holds 5.

step 1 of 5