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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:07:52+00:00 2026-05-30T03:07:52+00:00

My JS-code has array arrayResults , some element of him can be undefined –

  • 0

My JS-code has array arrayResults, some element of him can be “undefined” – this is feature of algorithm. To check that there is no such elements I use the follow code:

for (i in arrayResults)
        {
          if (typeof(arrayResults[i])=='undefined')
           {
              // ask user to repeat
           };
        };  

But, using the debugger, I found that JS-engine passes the “undefined”-item of array (in for condition), respectively I don’t have the possibility to make the comparing and make the follow instructions.

So, is there any way to really check the “undefined” items in array? (I can’t to set items of array in sequence, because if I found the position of “undefined” item, I tell to user to go to this position).

  • 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-30T03:07:53+00:00Added an answer on May 30, 2026 at 3:07 am

    Don’t use a for..in loop to iterate arrays. If you are interested in the reasons, please read this StackOverflow question. They should only be used for traversing objects.

    Use a simple oldschool for loop instead, it will solve your problem.

    for (var i = 0, l = arrayResults.length; i < l; i++) {
        if (typeof(arrayResults[i])=='undefined') {
             // ask user to repeat
        };
    };  
    

    jsFiddle Demo

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

Sidebar

Related Questions

Right, this code goes through a rather large multidimensional array (has about 28,000 rows
Which one below is correct? First code has no quotes in the $_GET array
This code has an interesting bug: some_struct struct_array1[10] = {0}; some_struct struct_array2[10] = {0}
My code has something like this: HttpFileCollection files Instead of looping through each file
So this code has the off-by-one error: void foo (const char * str) {
I'm guessing the StackOverflow code has something along the lines of a UsersController that
I was wondering if this code snippet is considered legal: $arr = array(123,456,789,123,456,789); foreach($arr
I am modifying a Json document through code. The Json has array nested items.
I’m 100% certain this code has been working before. Now it strangely doesn’t. The
I have three PHP arrays that I've encoded with json... extra PHP code has

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.