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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:23:57+00:00 2026-06-13T08:23:57+00:00

I have a for loop which iterates through currentObject in response. This code: console.log(response[currentObject]);

  • 0

I have a for loop which iterates through currentObject in response.

This code:

console.log(response[currentObject]);

Clearly shows that response[currentObject] has among other properties, “start”.

However, this code tells me the variable is undefined:

console.log(response[currentObject].start);

Why is this? Note that “start” is a date variable.

Here is the whole function:

function(response) {

                            for (var currentObject in response) {
                                //Parsing the data before its used
                                //"17\/10\/2012 20:55:00"
                                var phpStartDate = response[currentObject].start;
                                console.log(response[currentObject]);
                                var phpStopDate = response[currentObject].stop;
                                var datePartsStart = phpStartDate.match(/(\d+)/g);
                                var datePartsStop = phpStopDate.match(/(\d+)/g);
                                var parsedDateStart = new Date(datePartsStart[2], datePartsStart[1], datePartsStart[0], datePartsStart[3], datePartsStart[4], datePartsStart[5]);
                                var parsedDateStop = new Date(datePartsStop[2], datePartsStop[1], datePartsStop[0], datePartsStop[3], datePartsStop[4], datePartsStop[5]);

                                response[currentObject].start = parsedDateStart;
                                response[currentObject].stop = parsedDateStop;
                                //debugger;
                            };
                            return response;
                        }

Forgot to add, I’m using jQuery 1.8.2, which I believe handles dates differently than 1.7 (but I can’t use 1.7 because I had a whole bunch of other problems with it!)

Here is the output of console.log(response):Object

data: Array[3]
0: Object
hourly: "4.00"
id: "40"
staff: "James Hadley"
start: "2012-09-25 00:00:00"
stop: "2012-09-27 00:00:00"
__proto__: Object
1: Object
hourly: "25.00"
id: "39"
staff: "James Hadley"
start: "2012-10-17 21:12:00"
stop: "2012-10-26 02:30:00"
__proto__: Object
2: Object
length: 3
__proto__: Array[0]
total: 3
__proto__: Object
  • 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-13T08:23:58+00:00Added an answer on June 13, 2026 at 8:23 am

    I guess it’s a timing issue, because the console.log object is live. Try

    console.log(JSON.stringify(response[currentObject]));
    

    I bet it does NOT include start even thought without stringify it does. Your response is asynchronous and you access start too early (your code doesn’t show that part).

    Now with your comment it’s obvious. It’s an array and you are missing and index, e.g. 0.

    console.log(response[currentObject][0].start);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code which iterates through ArrayList<String> towns = new ArrayList<String>(); using JSTL
I have a loop that iterates through elements in a list. I am required
Suppose I have a for loop that iterates over a generator and in this
I currently have a loop which iterates through an NSArray of NSString objects. I
In my program I have a while loop which iterates through an array list
I have a loop which basically calls this every few seconds (after the timeout):
During program optimization, trying to optimize a loop that iterates through a vector, I
I have the following loop which shows the fields money and percent. I want
I have made an each statement which iterates through each class item found. At
Working of foreach: As I know, foreach is a loop which iterates through a

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.