Results 1 to 3 of 3

Thread: Object child, referenceing the parent or constructor?

  1. #1
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Object child, referenceing the parent or constructor?

    Hi, so here's the problem....

    I create an object with new

    Code:
    new Owner();
    
    function Owner()
    {
    new Pet();
    }
    
    function pet()
    {
    this.parent = ????????
    }
    How do I reference the constructors object, which is the question marks?


  2. #2
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Well I found a work around

    Just pass the parent object as an argument

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Using arguments when parent is already specified may cause some problems. Two variables are defined, obj.parent, and arguments[0]. They may overlap.

    How do I reference the constructors object, which is the question marks?
    pet.parent I think. I'm not sure if functions are meant to be objects in this case.
    If you did:
    Code:
    var t = new pet();
    alert(t.parent)
    In this case, t is the object and parent is one of it's nodes.
    - Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •