Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:54:12+00:00 2026-06-04T11:54:12+00:00

Given class A and class B, where class B inherits from class A …

  • 0

Given class A and class B, where class B inherits from class A …

// Define class A
dojo.declare("mynamespace.A",null,{
    myMethodA: function() { this.myMethodB() }
});

// Define class B
dojo.declare("mynamespace.B",mynamespace.A,{
    myMethodB: function() {}
});

Is it legal to call this.myMethodB() in the scope of class A (parent class)?
I have seen this in a piece of software and I do not understand it. I know that in Java, this is not possible unless you typecast A to B. But is dojo any different?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:54:13+00:00Added an answer on June 4, 2026 at 11:54 am

    Your buzzword of this question would be this.inherited(arguments);
    Your question goes for calling a method which is not in the current inheritance scope – and would by a true object oriented programmer be called invalid.. However it is possible (still) since the loader declared everything in global scope, e.g. you can access any module via mynamespace.X and then add prototype.theMethod.

    Once you have inheritance as in mynamespace.B all of the functionalities of both A and B are ‘this’ scoped. It is simply like a merged hash of stuff, say for all methods and variables in A do set instance B[key] = property A[key].

    However if you would encounter an override where the property is prototyped for both ‘class’ A and B – there is a mechanism in the declare / construct chain which allows for calling ‘super’ (or parent class, following your notation).

    For the special property constructor it is allways so, that the inheritance bubbles[period].

    For any methods that are declared only once, you cannot with respect of yourself call it if it is not an inherited method – and it will then be accessible via ‘this’

    For any methods which have overrides, the function ‘this.inherited(arguments);’ will send you upwards, one tick to the current parent class of callee. Look at the extended fiddle here

    var AClass = dojo.declare("mynamespace.A", null, {
        constructor: function(args) {
            this.overriddenMethod();
        },
        overriddenMethod: function() {
    
        }
    });
    var BClass = dojo.declare("mynamespace.B", [AClass], {
    
        constructor: function() {  },
    
        overriddenMethod: function() {
            // call super before anything else is processed in this method
            // by placing following call you can control function callflow
            this.inherited(arguments);
        }
    });
    
    // will call A.constructor, then A.overriddenMethod
    new AClass();
    
    // will call B.constructor, A.constructor, B.overriddenMethod and then
    //  A.overriddenMethod via the call to super
    //  in B.overriddenMethod which A.constructor 
    //  calls (note that A.constructor callflow 'aims' B.override not A.override)
    new BClass();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that inherits from defaultdict like this: class listdict(defaultdict): def __init__(self):
I have to select an <a> element from the given class of objects. when
I have a class which inherits from CListCtrl class, say class list. I have
I wanted to make a linked list class ListList that inherits from a class
I have an instance of a class called AccessData, which inherits from DbContext. So
I've got two classes: a template class, and a regular class that inherits from
I've got a simple class that inherits from Collection and adds a couple of
I have a class that inherits from a dictionary in order to add some
I'm working on a class that inherits from another class, but I'm getting a
I'm using a django module that uses a class that inherits from dict. Let's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.