Pages

Saturday, August 13, 2016

Cool javascript functions part 1

function happy(a){
  a = null;
}

x = [];
happy(x);
x = ?

What will x equal?

The answer is in the comments.

1 comment:

  1. x will equal = [];

    Yes, x will still equal an empty array. The value of x, which is an empty array, is what is passed to the function happy, not the variable x itself.

    ReplyDelete