Linked Questions

14 votes
4 answers
4k views

I read somewhere (sorry, I can't find the link) that the For...In loop is not recommended for arrays. It is said here: http://www.openjs.com/articles/for_loop.php that it is meant for associative ...
17 votes
3 answers
12k views

This would be a very easy question for all you javascript/jquery guys. I've been programming javascript from past 2 years and today I faced a strange problem. I am fetching a JSONarray from my C# ...
9 votes
1 answer
8k views

Possible Duplicate: JavaScript “For …in” with Arrays People always tell me that using FOR IN is a bad practice, please could you tell me why? And why is better to use for with i?...
Adam Halasz's user avatar
  • 58.5k
11 votes
3 answers
2k views

I am reading MDN docs for better understanding javascript. This is an excerpt from there Object.prototype.objCustom = function() {}; Array.prototype.arrCustom = function() {}; let iterable = [3, ...
Srinivas's user avatar
  • 554
9 votes
3 answers
5k views

I have a JSON String being parsed (in a response var) from AJAX: The JSON { "TheArray":[ { "AlmostThere": { "whatWeAreLookingFor":"Hello" } }, ...
Momo's user avatar
  • 3,900
1 vote
5 answers
26k views

I am learning JavaScript and now I am trying to run the following codes in Node to display the values in an array: let array = [1, 2, 3]; for (let a in array) { console.log(a); } I expect the ...
Kelvin's user avatar
  • 396
3 votes
1 answer
3k views

What is the most efficient way to check a certain condition on every element of an array and return false if one or more elements do not meet the condition, for example, I have this array for example ...
2 votes
3 answers
3k views

Possible Duplicate: JavaScript “For …in” with Arrays I'm trying to use the for-in syntax to loop through an array of numbers. Problem is, those numbers are getting converted to ...
6 votes
5 answers
552 views

I always use for (i=0; i<array.length; i++) when looping through arrays. I always use for (var i in object) when looping through object properties. I can't use for (i=0; ... ) for object ...
2 votes
2 answers
3k views

I use phpstorm and over the past half a year or so it started warning me about code like this: for( let key in attachmentPaths ){ requestObject.formData.attachments.push( fs....
user avatar
8 votes
1 answer
1k views

Possible Duplicate: JavaScript “For …in” with Arrays In which situations using for (var i = 0; i < array.length; i++) is different from using for (var i in array) in ...
user avatar
0 votes
3 answers
1k views

var table = document.querySelectorAll(".numbers"); function seppuku() { for (let i in table) { table[i].style.color = "red"; } } seppuku(); <div class="numbers">1</div> &...
0 votes
3 answers
2k views

I have worked out two ways of calculating the same thing in my JavaScript. I just wonder which is more efficient in terms of memory usage and processing power: AveragePL = netArray.reduce((sum,arr) =&...
0 votes
1 answer
661 views

Where y is an array of objects, y = [ {property:"",property2:""}, {property:"",property2:""}, {property:"",property2:""}, {property:"",property2:""}, {property:"",property2:""} ] ...
1 vote
1 answer
1k views

I have following code snippet: console.log('**1**',parentNode.child.length); //1 for(var ch in parentNode.child) { console.log('PTree root child',parentNode....

15 30 50 per page
1
2 3 4 5
...
56