Calling variables defined in an external function from an internal function using the debugger

From jQuery docs javascript guide :

Since the local area works through functions, any defined functions inside another have access to the variables defined in the external function:

function outer() {
    var x = 5;
    var y = 2;
    function inner() {
        console.log( x );
        debugger; // <-- !!!
    }
    inner();
}
outer()

The console starts with debugger:

> x
5
> y
ReferenceError: y is not defined

Since the variables defined in the function outercan be used by the function inner(for example, xor y), why can't the debugger call the variable y?

, , , / . , . , , , , .

, ,, y ? ( , , outer.y)

:

-, javascript. Python pdb, , :

def outer():
    x = 5
    y = 2
    def inner():
        print x
        import pdb; pdb.set_trace()
    inner()
outer()

(Pdb) x
5
(Pdb) y
*** NameError: 'y' is not defined
+4
1

, JavaScript. y , . , .

y (, console.log(x, y)), x, y, .

- - y ?

-, . y inner ( , ).

+5

All Articles