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 7170143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:09:06+00:00 2026-05-28T15:09:06+00:00

var super_class = function(p) { this.p = p + 1; this.method = function(a, b)

  • 0
var super_class = function(p) {
    this.p = p + 1;
    this.method = function(a, b) {
        // some code
    };
};

var base_class = function(o) {
    this.o = o;
    super_class.call(this, o);
    this.method = function(a, b) {
        // call super_class .method();
        // some code
    }
}

base_class.prototype = new super_class();

var bc = new base_class(0);
var v1 = bc.o; // 0
var v2 = bc.p; // 1

How can I call the super_class method when the name and properties are supposed to be identical. If I changed the name, I would just call this.method(3, 4); from within another function. I’m creating an extension class to another extension class, so changing the name of the function will not help me.

Also, storing the function in a private variable var pmethod = this.method; is sloppy at best.

  • 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-05-28T15:09:06+00:00Added an answer on May 28, 2026 at 3:09 pm

    Your current implementation has an error at super_class(this, o);. Either replace it with super_class.call(this, o), or correctly implement an initializer method:

    // Basic super class method.
    var Super_class = function(p) {
        this.init(p); // Call initializer
    };
    
    // Define prototype properties and methods
    Super_class.prototype = {
        constructor: Super_class,
        init: function(p) { this.p = p + 1; },
        method: function(a, b) {
            console.log("Super class method, arguments: " + [a,b]);
        }
    };
    
    // Define base_class
    var Base_class = function(o) {
        this.o = o;   // Initialize `o` property
        this.init(o); // Initialize p variable through the initializer
    };
    // Extend `Base_class` prototype with `method`.
    Base_class.prototype.method = function(a, b) {
        // Call the method from the parent = Super_class.prototype.method
        this.constructor.prototype.method(a, b);
    };
    
    Base_class.prototype = new Super_class; // Set prototype to `super_class`.
    
    var bc = new Base_class(0);
    var v1 = bc.o; // 0
    var v2 = bc.p; // 1
    bc.method('Hi: ', [v1, v2]); // Prints "Super class method, arguments: Hi [0,1]"
    

    Alternatively, you can also push all methods of Base_class in Base_class itself and/or create a reference to the parent class:

    // Define base_class
    var Base_class = function(o) {
        var __super__ = this.constructor.prototype;
        this.o = o;   // Initialize `o` property
        this.init(o); // Initialize p variable through the initializer
        Base_class.prototype.method = function(a, b) {
            // Call the method from the parent = Super_class.prototype.method
            __super__.method(a, b);
        };
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var y = new w(); var x = y.z; y.z= function() { doOneThing(); x();
function Person(name) { this.name = name; this.say = function() { console.info('I am ' +
var insInvoice = new NpgsqlCommand( @INSERT INTO invoice_detail( invoice_id, invoice_detail_id, product_id, qty, price, amount)
var newUser = new tblUser() { Email = strEmail, Password = strPassword, DateBirth =
var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});
var query1 = urlencode($('input[name=searchTerm1]').val()); //user1 var query2 = urlencode($('input[name=searchTerm2]').val()); //user1 var rpp = 20;
var query1 = urlencode($('input[name=searchTerm]').val()); //user1 $.getJSON('http://twitter.com/friends/ids.json?screen_name='+ query1 +'&jsoncallback=?', function(data){ $('content').append(''+data.length+''); }); This is a
I was wondering the difference between these two dispatchEvent method... //1. eventObj:YouTubeSearchEvent = new
So I have made this simple interface: package{ public interface GraphADT{ function addNode(newNode:Node):Boolean; }
I have a action script from a decompile flash like this public function getResourceAsByteArray(resID:int):flash.utils.ByteArray

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.