0

Can someone help me with the code below I am expecting the output

x = 10
y is not defined
z = undefined

But when I executed it showing the results

x = 10
y = 100
z = undefined

var x = 10;
var z;

function f(z) {
  var x = y = z = 100
}
f(10);
console.log(x, y, z)
VLAZ
  • 22,934
  • 9
  • 44
  • 60
  • 1
    You haven't declared `y` with `var`, so you are just assigning to an implicit global in the function. – VLAZ Jun 16 '21 at 05:53

0 Answers0