Accessing an objects parent class

Discussion in 'Javascript' started by eggie5@gmail.com, Jul 1, 2007.

  1. Guest

    See the below objects:

    function Manager()
    {
    this.reports=new Reports();
    }

    function Reports()
    {
    //How do I access Manager from here?
    }
    , Jul 1, 2007
    #1
    1. Advertising

  2. RobG Guest

    On Jul 1, 9:57 am, "" <> wrote:
    > See the below objects:
    >
    > function Manager()
    > {
    > this.reports=new Reports();
    > }
    >
    > function Reports()
    > {
    > //How do I access Manager from here?
    > }


    You can get the function that called a function using:

    arguments.callee.caller;

    so

    function Reports() {
    //How do I access Manager from here?
    var caller = arguments.callee.caller;
    }

    does the job in those browsers that support it (Firefox and Safari at
    least, I don't think IE does) - but I can't see how that's useful.

    It is usually better to explain what you are trying to do at a higher
    level, then maybe someone will tell you how to do it, rather than
    asking for how to do something explicit that has no obvious rationale.


    --
    Rob
    RobG, Jul 1, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Suzanne Vogel
    Replies:
    5
    Views:
    2,328
    Dan W.
    Dec 9, 2003
  2. 7stud
    Replies:
    11
    Views:
    661
    Dennis Lee Bieber
    Mar 20, 2007
  3. metal
    Replies:
    8
    Views:
    485
    Bruno Desthuilliers
    Oct 30, 2009
  4. Christoph Haas

    Accessing parent objects

    Christoph Haas, Oct 5, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    79
    Christoph Haas
    Oct 5, 2003
  5. Derek Basch
    Replies:
    4
    Views:
    177
    -berlin.de
    Aug 16, 2006
Loading...

Share This Page