Barleby
Barleby

Reputation: 688

Output var values declared inside a jquery $(document).ready() from Firebug Console

I have something like:

$(document).ready(function() {
    var numberOfTables = 3;
});

Is there anyway that I can access numberOfTables value from Firebug Console, without having to type inside my script something like: console.out(numberOfTables)?

Upvotes: 2

Views: 535

Answers (3)

Mikael Härsjö
Mikael Härsjö

Reputation: 1036

Add debugger; inside your function (after declaring your var). Firebug will stop executing the script. Then you can just hover numberOfTables to see its value.

Upvotes: 1

Royi Namir
Royi Namir

Reputation: 148534

numberOfTables is internal scope.

so you cant see it

however consider removing the VAR keyword ( just for debugging !!!)

and it will global

so you can see it.

Upvotes: 2

Anders Marzi Tornblad
Anders Marzi Tornblad

Reputation: 19305

When the variable goes out of scope, there is nothing you can do to access it. You could set a breakpoint and examine the variable in the debugger without using console, but it will only be valid while in scope.

Upvotes: 1

Related Questions