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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:20:08+00:00 2026-06-14T15:20:08+00:00

I have a problem with return a value from an object. my object looks

  • 0

I have a problem with return a value from an object.
my object looks like this.

   function XYZ(date, startT)
     {
     var _date=date;
     var _startT=startT;
     this.get_date = function() {
       return _date;
       };
      this.set_date = function(value) {
        _date=value;
      };
       this.get_startT = function() {
       return _startT;
       };
       this.set_startT = function(value) {
       _startT=value;
      };
      this.toString()
      return (_date + " " _startT);
      }

then i create an Array like this

   jsData[0] =new XYZ("2012-11-11","8:00");
   jsData[1] = new XYZ("2012-03-03","8:00");

when i want to use get_date method it didn’t return me the value but the get_startT method works fine.
When i show object with .toString method it also show me full object

Please help.

  • 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-14T15:20:09+00:00Added an answer on June 14, 2026 at 3:20 pm

    It works if you fix all the syntax errors:

    function XYZ(date, startT) {
      var _date=date;
      var _startT=startT;
      this.get_date = function() {
        return _date;
      };
      this.set_date = function(value) {
        _date=value;
      };
      this.get_startT = function() {
        return _startT;
      };
      this.set_startT = function(value) {
        _startT=value;
      };
    }
    
    var jsData = [];
    jsData[0] = new XYZ("2012-11-11","8:00");
    jsData[1] = new XYZ("2012-03-03","8:00");
    
    display("jsData[0].get_date() = " + jsData[0].get_date());
    

    Output:

    jsData[0].get_date() = 2012-11-11

    Live Copy | Source

    Other than obvious typos, here’s what I did:

    • Put { and } around the function body.

    • Removed the this.toString() which was non-functional (a no-op, as you didn’t store the result anywhere).

    • Removed the return at the end, because returning a string primitive out of a constructor function is another no-op.

    • Declared jsData.

    • Initialized jsData.

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

Sidebar

Related Questions

I have a function that looks like this: def getCurrentShow(hour=(localtime().tm_hour),day=datetime.datetime.now().strftime('%A')): return Schedule.objects.get(hour=hour,day=day).show so I
I have a problem with Json formating returned from .ASMX I need to return
I have an odd problem when using the return result of a function and
I have an API that returns a promise from a deferred object. The problem
I have a table in SQL Server which looks like this: ID Code Name
I have a problem mapping a Json object recieved from the server into a
I have problem understanding what the return fibonacci( number-1 ) + fibonacci( number-2 )
I have a problem when using jsonp to API HTTPS website. it will return
I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I find myself often faced with this problem: I have a dictionary where the

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.