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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:56:30+00:00 2026-06-11T01:56:30+00:00

I am coding something in JS and I have to test code – I

  • 0

I am coding something in JS and I have to test code – I have to check if elements in 2 arrays are the same.
So I’ve got an array: boreholes = [[66000, 457000],[1111,2222]....]; and I want to check if this array contain element for eg. [66000,457000] so I did:
boreholes.indexOf([66000,457000]) but it returns -1, so I iterate trough array by:

for (var i = 0; i< boreholes.length; i++){
 if (boreholes[i] == [66000, 457000]){
  console.log('ok');
  break;
 }
};

but still I’ve got nothing. Can someone explain me what am I doing wrong?

  • 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-11T01:56:32+00:00Added an answer on June 11, 2026 at 1:56 am

    You are comparing distinct objects. When comparing objects, the comparison only evaluates to true when the 2 objects being compared are the same object. I.E

    var a = [1,2,3];
    var b = a;
    a === b //true
    b = [1,2,3];
    a === b //false, b is not the same object
    

    To compare arrays like this, you need to compare all of their elements separately:

    for (var i = 0; i < boreholes.length; i++) {
        if (boreholes[i][0] == 66000 && boreholes[i][1] == 457000) {
            console.log('ok');
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an entity which looks something like this: (I'm coding to the web
I have some test code (as a part of a webapp) that uses urllib2
Does iPhone key-value-coding have a way to test whether a class will accept a
First off, I'm a complete beginner at C++. I'm coding something using an API,
I was coding today and noticed something. If I open a new interpreter session
In Objective-C on Apple there is something called Key-Value Coding that allows you to
When someone codes something for example in MASM, what is it called? Coding in
Coding i came around to check for the vararg performance of Java. I write
I have several files with code testing code (which uses a unittest class). Later
I have been coding in a project with over 500 class. One of 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.