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

41938Re: Execution Scope and Functions/Objects/Classes/etc

Expand Messages
  • Michael Hasenstein
    Dec 4 2:56 AM
    • 0 Attachment
      One more thing I forgot... (okay I'll stop now - one can easily write a book... oops, I guess that's already been done :-) )

      --- I wrote:
      > Let's do a check (only works in Firefox!):
      > a.__proto__ === F.prototype
      > returns "true" (by using === we assure that the objects are indeed
      > identical, i.e. the two variables point to the same memory location)

      There's also a property called constructor.  It points to the actual constructor function itself:

      a.constructor === F


      b = {}
      b.constructor === Object

      (unless the user overwrites the property) object.constructor.prototype points to the same object as __proto__ but is official and works in all Javascript implementations.

      Among other things, YUI uses these to build a property superclass when using YAHOO.lang.extend. You can also use it to implement your own  "instanceof" functionality. However, only the (JS interpreter implementation specific) secret link property is used to look for functions in the inheritance chain by the JS interpreter.
    • Show all 25 messages in this topic