Function foox var z 3 return x 2 var z 5 var p foo z At
Function foo(x) {var z = 3; return x + 2;} var z = 5; var p = foo (z); At the end of this snippet the values of z and p are
Solution
Since the var z is declared at two places withing the js file and within the function foo.
For function foo var z is local variable
For main js file var z becomes global variable.
Hence when var z = 5 is declared value of z will be 5.
and value of var p is 5+2 which is 7.
Hence the answer is z is 5 and p is 7.
