Seems like a problem of scope. When you run console.log(obj2) it's
running within the global window scope. You create the obj2 object
with the scope of the initialize function. You could either change
your code to:
<script type="text/javascript">

   var obj2, obj1 = new Object();
    function initialize() {
      obj2 = new Object();
      alert('obj2 initialized!');
    };
    initialize();
</script>

or to:
<script type="text/javascript">

    obj1 = new Object();
    function initialize() {
      var obj2 = new Object();
      console.log('obj2 initialized!');
    };
    initialize();
</script>
On Sep 8, 11:21 pm, Hong Kil Dong <[email protected]> wrote:
> On 8 сен, 15:36, Pedro Simonetti Garcia <[email protected]>
> wrote:
>
> > Hi there,
>
> > 2010/9/8 Hong Kil Dong <[email protected]>:
>
> > Not directly, but you could use console.log(localVarName), and
> > then, when clicking on the object in the console result, you'll see
> > that local object in the DOM panel.
>
> Can't reproduce such behavior.
>
> I inserted this code in my page:
>
> <script type="text/javascript">
>
>     obj1 = new Object();
>     function initialize() {
>       var obj2 = new Object();
>       alert('obj2 initialized!');
>     };
>     initialize();
> </script>
> lunched it, and after message 'obj2 initialized!' appeared I issued
> console.log(obj2) command, but it still returned ' ReferenceError:
> obj2 is not defined { message="obj2 is not defined",  more...}'

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.

Reply via email to