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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:04:04+00:00 2026-06-07T19:04:04+00:00

I have a 2-dimensional array that I want to check the bounds in Javascript.

  • 0

I have a 2-dimensional array that I want to check the bounds in Javascript. I prefer doing this without checking each index independently.

For example if my 2d array is…

dataset[row0-1][column+column0]

I really do not want to have to do the following…

if(row0-1 >0)
{
    if(dataset[row0-1].length >= column+column0)
    {
        data = {label : dataset[row0-1][column+column0]};
    }
}

The problem is that I have to first check the row and then check the column. I prefer doing both of these checks with one operation or on one line. Rather then returning an out of bounds error, why doesn’t Javascript just return null or undefined?

For example, in a future version of Javascript, wouldn’t it be better if we could do this?

if(dataset[row0-1][column+column0] != undefined)
{
   data = {label : dataset[row0-1][column+column0]};
} 
else 
{
    ...
}
  • 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-07T19:04:05+00:00Added an answer on June 7, 2026 at 7:04 pm

    I think the reason for checking each index independently is because each dimension can have different lengths on each index.

    I know C# has Multidimensional Arrays, but Javascript uses Jagged Arrays.

    I do not picture this changing any time soon.

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

Sidebar

Related Questions

I have an multi-dimensional array that I want to send to a PHP script
I have a 2-dimensional numpy array that looks like this: [[a b c] [d
I have a 2-dimensional array in Ruby that I want to produce a working
I have a multi-dimensional array that looks like this: The base array is indexed
I have a multi-dimensional array similar to the example below that I want to
I have a 2-dimensional array of objects and I basically want to databind each
I have a multi-dimensional array and what i want is in each second degree
I have a three-dimensional array that I want to reset to zero. It seems
I have a multi-dimensional array, which basically consists of one sub-array for each year.
I have a two-dimensional array. When I print/dump this I get the following My

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.