object's prototype variable inheritance

Discussion in 'Javascript' started by LittleNipper, Aug 29, 2006.

  1. LittleNipper

    LittleNipper Guest

    I'm looking to do something like this:

    function superDuperObject(range) {
    this.startContainer = new superDuperObjectStartContainer(range);
    }

    function superDuperObjectStartContainer(range) {
    this.calculatedContainerNumber = doSomethingAndGetSomethingBack(range);
    return range.startContainer
    }

    function doSomethingAndGetSomethingBack(range) {
    return
    someCoolInformationThatICalculateInThisFunctionThatNeedsTheRange;
    }

    var myObject = new
    SuperDuperObject(DOMRangeObjectThatIDefindedEarlierInCode);

    // Show me the startContainer of
    "DOMRangeObjectThatIDefindedEarlierInCode"
    alert(myObject.startContainer);

    // Show me the calculatedContainerNumber that I get from a function
    that does stuff with the range passed to it
    alert(myObject.startContainer.calculatedContainerNumber);

    Thanks!
     
    LittleNipper, Aug 29, 2006
    #1
    1. Advertisements

  2. LittleNipper

    LittleNipper Guest

    By the way - the above doesnt work.. when you return the
    alert(myObject.startContainer) is gives you a message saying something
    like "undefined"...
     
    LittleNipper, Aug 29, 2006
    #2
    1. Advertisements

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. June Lee
    Replies:
    2
    Views:
    1,048
    Jim Cobban
    Apr 13, 2008
  2. Daniel Moore
    Replies:
    5
    Views:
    191
    Daniel Moore
    Jul 26, 2009
  3. stephane
    Replies:
    2
    Views:
    255
    stephane
    Sep 20, 2005
  4. Replies:
    9
    Views:
    437
    Thomas 'PointedEars' Lahn
    May 26, 2006
  5. Replies:
    6
    Views:
    155
    John G Harris
    Jan 13, 2007
  6. Replies:
    3
    Views:
    501
  7. Jessica
    Replies:
    8
    Views:
    182
    John G Harris
    Dec 2, 2007
  8. javascript fish
    Replies:
    0
    Views:
    329
    javascript fish
    Oct 11, 2008
Loading...