Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the array I’ve: 

[{prop1:"abc",prop2:"qwe"},{prop1:"bnmb",prop2:"yutu"},{prop1:"zxvz",prop2:"qwrq"},...]

I want to get the index 1 with the given condition prop2=="yutu". Can anyone tell me how can I do it without  iterating over the entire array?

1 Answer

0 votes
by (19.7k points)

You can make use of the XMLHttpRequest object provided by browsers(dashcode) to make HTTP requests in JavaScript like below:

function httpGet(theUrl)

{

    var xmlHttp = new XMLHttpRequest();

    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request

    xmlHttp.send( null );

    return xmlHttp.responseText;

}

Interested in Java? Check out this Java tutorial by Intellipaat.  

Browse Categories

...