Loading ...
Sorry, an error occurred while loading the content.

1404Re: [jslint] Re: top of inheritance chain

Expand Messages
  • Mark Volkmann
    Aug 1, 2010
      On Fri, Jul 30, 2010 at 3:49 PM, Douglas Crockford <douglas@...>wrote:

      > > Can someone explain why the second line below outputs false?
      > > I thought since the first line outputs true, the second would also.
      > >
      > > print(Object.prototype.isPrototypeOf(String.prototype)); // true
      > > print(String.prototype.prototype === Object.prototype); // false; Why?
      > prototype is a property of a constructor function, it is not the property
      > through which an object delegates to another object, which is the key to
      > inheritance. In some implementations, the delegation property is surfaced as
      > __proto__, which is distinct from prototype.

      Thanks for explaining that! I think I've almost connected all the dots.

      function Foo() {}
      var foo = new Foo();

      All of these line print "true" in Rhino:

      print(foo.constructor === Foo);
      print(Foo.constructor === Function);
      print(Foo.constructor.prototype === Function.prototype);

      Can someone explain why the last two lines print "false"?

      print(Function.constructor.prototype === Object.prototype);
      print(Function.constructor === Object);

      Maybe my assumption that all function objects inherit from Object.prototype
      is wrong.

      R. Mark Volkmann
      Object Computing, Inc.

      [Non-text portions of this message have been removed]
    • Show all 8 messages in this topic