It must have been set by the page. Check the *DOM* panel 
<https://getfirebug.com/wiki/index.php/DOM_Panel> to see your variable 
listed there. You can simply confirm that this variable is unrelated to any 
devtool by adding an alert(foo) at the first line of your function and not 
have any devtool open when you're calling it.

To debug where it gets set, set the variable as watch expression and step 
debug through the code to see when it gets set.

Sebastian

On Friday, January 1, 2016 at 11:42:20 PM UTC+1, San wrote:
>
> This is such a basic question that it will probably make me look like an 
> idiot, but anyway...
>
> I have an element in my document:
>
> <p id="foo">...
>
> I'm writing a new JS function (in a linked JS file), and sending it a 
> single argument, the ID of an element in the document. My real intention 
> was to send it as a string, but just for the hell of it, I called the 
> function without stringifying or "getting" the element first, just using 
> the bare ID identifier like this:
>
> myNewFunction( foo ) { ...
>
> I thought the function would throw an error ("what's foo?"). But it's not 
> -- the function is receiving it as a complete reference to the actual 
> element. I don't understand this, because I did NOT do any of these:
>
> $(foo)
> or 
> document.getElementById("foo")
> or anything like that.
>
> I have no idea what's happening... so in Firebug, I tried just typing into 
> the console:
>
>     foo
>
> And just as in my function, Firebug didn't say "undefined" or throw an 
> error; it returned a reference to the actual element as though I'd typed 
> document.getElementById("foo"). Why?
>
> When I asked Firebug what the typeof foo is, it told me it's an HTML 
> element! How does Firebug know what foo is? I didn't "get" it first!
>
> I tried the same thing in Chrome dev tools, with the same result.
>
> It's hard to figure out what's going on with the function because I'm not 
> sure what the Console convention (Firebug or Chrome) is. Is there some 
> convention that, as a "convenience" to you, if you just type in a bare ID, 
> and run it, the console resolves that to the actual element?
>
> This seems so basic I can't believe I'm confused about this, but I am...
> <http://Sanstudio.com>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/firebug.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/firebug/3e10786f-1179-4888-9df9-60ab4fe0c895%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to