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

  • SEARCH
  • Home
  • 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 864867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:32:58+00:00 2026-05-15T09:32:58+00:00

I am running into the following issue which has really got me stumped: I

  • 0

I am running into the following issue which has really got me stumped:

I have

function SystemList(UID)
{
  this.refreshData();
}

SystemList.prototype.refreshData = function()
{
  this.systemDataObj({}, $.proxy(this.readSuccess, this));
}

When I try and run this, I get the following error: Uncaught TypeError: Object # has no method ‘refreshData’ within the constructor.

Anyone have an idea why this is failing? To my eye it looks like it should be working.

Edit:

Example of how I create an instance:

function UserMiniProfile(UID)
{
  this.UID = UID;
  this.systemList = new SystemList(this.UID);
  this.htmlID = 'user-'+this.UID+'-profile';
}
  • 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-15T09:32:59+00:00Added an answer on May 15, 2026 at 9:32 am

    I think you’re probably running into the issue of how and when function declarations vs. step-by-step code (what the spec calls statement code) happen.

    Code like this will fail in the way you describe, for instance:

    var obj = new Thingy("Fred");
    
    function Thingy(name) {
        this.setName(name);
    }
    
    Thingy.prototype.setName = function(name) {
        this.name = name;
    };
    

    …because you’re calling the constructor before adding the setName function to the prototype. Note that calling the constructor before its declaration is just fine, it’s just because the constructor is using a function that’s set up later by the statement code that there’s a problem. The order in which the JavaScript interpreter will try to process that code is:

    1. Create the function Thingy and make it available to the scope.
    2. Execute the var obj = .... line, calling the constructor.
    3. Execute the constructor’s code (which in this case throws an exception because there’s no this.setName function).
    4. Execute the Thingy.prototype.setName = ... line. (If no exception had been thrown in the last step, that is.)

    These steps happen for each script block (first the function declarations are done, then the statement code is executed in order), and even though the above example is fairly obvious, when you start putting together pieces from various different locations, you can create this situation less obviously.

    The solution, obviously, is to make sure you’re not constructing the object before you’ve set up the setName property:

    function Thingy(name) {
        this.setName(name);
    }
    
    Thingy.prototype.setName = function(name) {
        this.name = name;
    };
    
    var obj = new Thingy("Fred");
    

    …and again, the above is fairly obvious, but it’s possible to create these situations rather less obviously in the real world.

    My suspicion is that this is what’s happening in your case. It’s easy to prove: Using a debugger like Firebug on Firefox, VS.Net or the Script Debugger for IE, Chrome’s DevTools, etc., put a breakpoint on the SystemList.prototype.refreshData = ... line and a breakpoint on the line where you’re doing your new SystemList(...) and see which one executes first.

    Here are a couple of fiddles demonstrating the issue: This one fails in the constructor, this one succeeeds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running into the following issue, which applies to Server 2008 R2 only.
I am running into the following issue: Our members have a desire for personalized
EDIT: I am basically running into the following documented issue . I am using
I'm running into issues with the following code: var setupSearch = { searchSuggest: function(field)
Following this tutorial and running into trouble. [TestMethod] [ExpectedException(typeof(Exception))] public void VerifyPropertyNameMethod_NonExistentPropertyString_ThrowsException() { var
I'm running a stored procedure and have ran into a problem with the following
I'm running into issue which seems to indicate that ActionController::TestCase.get() method ignores what I
Deployed application to production and running into the following error on views that contain
I am running into trouble given the following setup: Operating System is Windows 7
I am running into some difficulty with the following query. SELECT maker, speed FROM

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.