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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:36:18+00:00 2026-05-23T08:36:18+00:00

base = function () { this.A = function () { this.B(); } var C

  • 0
base = function () {
  this.A = function () {
    this.B();
  }
  var C = function () {
    alert('I am C');
  }
}

sub = function () {
  this.B = function () {
    C();
  }
}

sub.prototype = new base();

(new sub()).A();

How can I tell the call to B() to evaluate with respect to the base class? (i.e. call c of the base class) Is this impossible?

  • 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-23T08:36:19+00:00Added an answer on May 23, 2026 at 8:36 am

    Normally I would recommend myFunc.apply and myFunc.eval; that’s what I interpret as “with respect to the base class” in javascript.

    However based on your title, you say “inside base class scope”; if I assume correctly that you are talking about closures and being able to refer to variables in outer functions, this is impossible, except perhaps with keeping an entrypoint into the closure into which you can pass in requests eval-style… but if you do that, you might as well have a an object like this._private.C.

    If you are attempting to keep things “private”, it is not really worth bothering to do so in javascript.

    If you say your motivation for this.C = function(){...} and access it as this.C(), I may be able to give a clearer answer.

    “That would allow C to be called on instances / essentially expose it. There’s no reason for it to be exposed since it’s supposed to be a helper method. I guess you could say my main frustration is that helper methods can’t be inherited by subclasses.” –OP

    In that case, it really isn’t private. However what you can do is define your helper method where it belongs: appropriately in an outer scope. =) For example:

    (function(){
    
      var C = function () {
        alert('I am C');
      }
    
      base = function () {
        this.A = function () {
          this.B();
        }
      }
    
      sub = function () {
        this.B = function () {
          C();
        }
      }
    
    })();
    
    sub.prototype = new base();
    
    (new sub()).A();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see a lot of code like this: function Base() {} function Sub() {}
I cant call protected function in my base class. Why? It looks something like
View this code: function testprecision(){ var isNotNumber = parseFloat('1.3').toPrecision(6); alert(typeof isNotNumber); //=> string }
Basically how do I call a base method using this patter below? var GS
I have a base class with an optional virtual function class Base { virtual
I have a base class Foo that has an Update() function, which I want
I have this code: $('.be-delete').live('click', function(e){ e.preventDefault(); var object =$(this); var url = $(this).attr('href');
I need to extend a class, which is encapsulated in a closure. This base
I have this base class package sevengames.miranda.front.res { import flash.display.MovieClip; import flash.text.TextField; public class
I defined my plugin base on http://docs.jquery.com/Plugins/Authoring (function( $ ){ var methods = {

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.