Pages

Saturday, August 13, 2016

Cool javascript functions part 2

swaparoo(a, b){
  var temp = a;
  a = b;
  b = temp;
}

x = 1;
y = 2;
swaparoo(x,y);


x = ?


Answer is in the comments!

1 comment:

  1. x = 1

    That's right. X will still equal 1. The value of the variable x is passed to the function, not the variable itself.

    ReplyDelete