Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14970 > unrolled thread
| Started by | juzna.cz@gmail.com |
|---|---|
| First post | 2012-07-09 10:49 -0700 |
| Last post | 2012-07-10 11:15 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.javascript
Access local & closure variables for debugging purposes juzna.cz@gmail.com - 2012-07-09 10:49 -0700
Re: Access local & closure variables for debugging purposes "Scott Sauyet" <3103invalid@webnews.fastusenet.org> - 2012-07-10 11:15 +0000
| From | juzna.cz@gmail.com |
|---|---|
| Date | 2012-07-09 10:49 -0700 |
| Subject | Access local & closure variables for debugging purposes |
| Message-ID | <ac883590-6b9c-4c27-a6b5-aa0b9e9c6c45@googlegroups.com> |
Hi,
when debugging javascript applications I often encounter a situation, where I need to see local variables of a function & variables which a function closes over ("closure variables").
This is possible in Chrome's Web Inspector in Scripts panel when I'm debugging - I can see "Scope Variables" panel on the right with sections Local, Closure and Global.
Is it somehow possible to access these variables from javascript itself? Probably within code running within webinspector's console.
Sample code:
(function() {
var x = 2;
window.myFunc = function() {
return x * x;
};
})();
console.gatherClosureVariables(window.myFunc) // would return { x: 2 } or something
Do you know if something like this is possible? Thanks
[toc] | [next] | [standalone]
| From | "Scott Sauyet" <3103invalid@webnews.fastusenet.org> |
|---|---|
| Date | 2012-07-10 11:15 +0000 |
| Message-ID | <201207101115423103@webnews.fastusenet.org> |
| In reply to | #14970 |
juzna.cz@gmail.com wrote:
> when debugging javascript applications I often encounter a situation,
> where I need to see local variables of a function & variables which a
> function closes over ("closure variables").
>
> This is possible in Chrome's Web Inspector in Scripts panel when I'm
> debugging - I can see "Scope Variables" panel on the right with sections
> Local, Closure and Global.
>
> Is it somehow possible to access these variables from javascript itself?
> Probably within code running within webinspector's console.
Those variables are available by name to your local code. You don't have
to do anything special to access the individual variables. But I don't
think any standard environments offer you facilities to list them.
-- Scott
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web