-4

Articles I've read on scope in javascript address what happens when you have nested variables/objects/functions defined in its parent scope. However, what happens if you have something like this:

function x(){

function y(){var u = 3;}
function z(){//is u available here?}

}
slynthin
  • 65
  • 3

1 Answers1

-1

var u in function y is not available in function z. However it will be accessible in you omit the var.

u = 3; // instead of var u = 3;

omitting the "var" will make the variable global.

eman.lodovice
  • 192
  • 1
  • 6