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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:51:47+00:00 2026-05-27T03:51:47+00:00

When I call the method getResult it returns an undefined value. What am I

  • 0

When I call the method getResult it returns an undefined value. What am I doing wrong?

var MyObjectResult = {"Success":1, "Fail":2, "Timeout":3, "None":4}

function MyObject()
{
   this.result = MyObjectResult.None;
   this.timout = 15;

   this.getResult = function ()
   {
      // Some calculation here and changing result
      // Logging (this.result shows that result has value of 1)
      this.result = MyObjectResult.Success;
      return this.result;
   }
}

var myObject = new MyObject();
var result = myObject.getResult();
// result is undefined
  • 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-27T03:51:47+00:00Added an answer on May 27, 2026 at 3:51 am

    I see nothing wrong with the code as posted, so I’m going to take a guess about what is in the code that you don’t show:

    Is the missing calculation code doing an ajax request (or some other asynchronous processing) and setting this.result in its success function? If so, the getResult() function will return immediately, before your aysnc processing has run its success or failure function to update this.result. If the logging mentioned in your comment occurs in the success/failure function then it would have the correct value.

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

Sidebar

Related Questions

Can I call public method from within private one: var myObject = function() {
I wanted to call Test1() Method Within WaitAndCallFunc() Function. Code: typedef void (*func)(); void
Uncaught TypeError: Cannot call method 'replace' of undefined highlight_termgithub.tokeninput.js:538 $.TokenList.selected_dropdown_itemgithub.tokeninput.js:557 e.extend.eachjquery.min.js:16 populate_dropdowngithub.tokeninput.js:556 $.TokenList.ajax_params.successgithub.tokeninput.js:670 f.extend._Deferred.e.resolveWithjquery.min.js:16
I call addNotify() method in class that I posted here. The problem is, that
Every time I call this method my NSMutableData is leaking and I cannot figure
I need to call a method that accepts a stream argument. The method loads
How can I call a method asynchronously ?
I have this method call I have to use... financial_document.assets.length But financial_document.assets could be
I need to call a method I have defined as: -(IBAction)next:(id)sender{ ... } I
When I call the method session.begin transaction as follows: //session factory is instantiated via

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.