constructors in JS



Hi,

if I Have

var f = function Foo(){}

new f().constructor.prototype.constructor === Foo is true???

here the prototype object should have Object not Foo as constructor.

and

why new f().constructor.prototype.constructor.prototype.constructor is
always the same
while

new f().__proto__.__proto__.__proto__ end correctly with null?









.



Relevant Pages

  • Re: The Most Challenging Interview Question
    ... How would you implement a constructor that inherits a method from ... var obj1 = new Foo, ...
    (comp.lang.javascript)
  • Re: constructors in JS
    ... var f = function Foo ... There is no variable called Foo after the previous code. ... var obj = new Foo; ... point to their constructor. ...
    (comp.lang.javascript)
  • Re: constructors in JS
    ... var f =  function Foo ... Don't name function expressions. ... here the prototype object should have Object not Foo as constructor. ...
    (comp.lang.javascript)
  • "this" in ctor
    ... Why does access to the _field variable fail without the "this"? ... thought that once _field was added to the prototype object (an ... This Foo value = 1! ... test2.js:11 ReferenceError: _field is not defined ...
    (comp.lang.javascript)
  • Re: C++ design question
    ... so anyone can instantiate it without ... > default constructor in the class header rather that allowing it to be ... > separately and initialize a pointer to it in Foo: ... fooDeriveN::DoStuffWithBarBase() at all because we have a Bar* in Foo*. ...
    (comp.object)