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. Advertising

  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. 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. June Lee
    Replies:
    2
    Views:
    778
    Jim Cobban
    Apr 13, 2008
  2. Replies:
    9
    Views:
    163
    Thomas 'PointedEars' Lahn
    May 26, 2006
  3. Replies:
    6
    Views:
    83
    John G Harris
    Jan 13, 2007
  4. Replies:
    3
    Views:
    252
  5. javascript fish
    Replies:
    0
    Views:
    155
    javascript fish
    Oct 11, 2008
Loading...

Share This Page