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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:42:24+00:00 2026-05-13T09:42:24+00:00

Note: Edited the sample to reflect my actual problem, which was a trailing comma

  • 0

Note: Edited the sample to reflect my actual problem, which was a trailing comma in the array initialization.

Seems that a mixture of raw array initialization and array.push can cause the indexes to get all whacky.

I do this:

var iFeelLikeIt = true;
var items = ["thing1", "thing2",];
if (iFeelLikeIt) {
  items.push("thing3");
}
items.push("thing4");

In IE7, (haven’t checked 6 or 8), my array looks like:

  • thing1
  • thing2
  • undefined
  • thing3
  • thing4

Actually, it looks more like a keyed-by-number dictionary, with keys for 0,1,3,4.

I’ve changed my code to just initializing an empty array and pushing everything onto it as needed, and it behaves sanely. But was wondering if anybody knew of a valid reason for this behavior? Or something that at least smells like a lame excuse for a valid reason.

  • 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-13T09:42:24+00:00Added an answer on May 13, 2026 at 9:42 am

    First of all, if i run your example it shows an error that thing1 is undefined. I guess you wanted to make it as string?
    Then, if I try to do this, iFeelLikeIt throws also error, cause it’s undefined.

    I assume you wrote in your code this :

    var items = ["thing1", "thing2",];
    

    Check the last comma at the end of the array. IE interprets it as the new undefined value, which will create array with next values:

    thing1, thing2 and undefined value.

    Nothing more than that.

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

Sidebar

Ask A Question

Stats

  • Questions 371k
  • Answers 371k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I agree with you completely, and I do sometimes use… May 14, 2026 at 7:05 pm
  • Editorial Team
    Editorial Team added an answer I ended up using the following: <siteMapNode url="javascript:window.open('Sample.doc','SampleName'); void(0);" title="FAQs"… May 14, 2026 at 7:05 pm
  • Editorial Team
    Editorial Team added an answer The code looks fine. Make sure you have the ACCESS_FINE_LOCATION… May 14, 2026 at 7:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.