constructor is part of the prototype. You wiped it out by assigning the
prototype to {}, which has a constructor of object.
On Jun 3, 2012, at 12:00 AM, dhruvbird wrote:
> Hello,
>
> I see different output for these 2 snippets of code. The only
> difference between them is that a prototype is defined on one of them,
> but not on the other.
>
> // Snippet-1:
> function Foo() { }
> var f = new Foo;
> console.log(f.constructor.name); // Prints "Foo"
>
> // Snippet-2:
> function Foo() { }
> Foo.prototype = { };
> var f = new Foo;
> console.log(f.constructor.name); // Prints "Object"
>
> Any idea why the behaviour changes by just adding a prototype?
>
> Regards,
> -Dhruv.
>
>
>
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users