Reputation: 10208
I'm still getting to grips with some of the JavaScript variable handling and I'm a bit confused over this.
I have a variable declared in a file like this:
(function (myControls, $, undefined) {
var selectedLifeArea;
...
But when looking for these in Firebug they aren't listed under the myControls "namespace" as I expected, only the functions are listed. Why is that?
Upvotes: 0
Views: 105
Reputation: 146302
Your code is wrapped in it's own scope.
Try adding some breaks in the js debugger, then you can read the variables.
Here is a brief description:
var globalVariable;
(function () {
var localVariable;
// can access both `globalVariable` and `localVariable`
...
)();
// can only access `globalVariable`
Upvotes: 2