Timeline for Loop through an array in JavaScript
Current License: CC BY-SA 4.0
79 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 23, 2022 at 8:37 | answer | added | Tom Bombadil | timeline score: -1 | |
Aug 5, 2022 at 13:29 | answer | added | Arun s | timeline score: 6 | |
Jun 13, 2022 at 8:49 | review | Suggested edits | |||
Jun 13, 2022 at 21:54 | |||||
May 8, 2022 at 17:25 | history | edited | Mateen Ulhaq | CC BY-SA 4.0 |
Shorten.
|
Nov 10, 2021 at 3:48 | answer | added | Alfredo Rahn Linde | timeline score: -1 | |
Oct 23, 2021 at 14:11 | comment | added | Bimoware | Why isn't this question answered, people have put gigantic enermy into putting a correct, formal, with pros and cons and no answer is confirmed? I don't see a single error on their answers. Please set an anwer as confirmed | |
Jun 15, 2021 at 14:03 | answer | added | Aleksandr Golovatyi | timeline score: 21 | |
Jun 5, 2021 at 6:21 | answer | added | Satish Chandra Gupta | timeline score: 103 | |
Apr 15, 2021 at 10:32 | review | Suggested edits | |||
Apr 15, 2021 at 19:22 | |||||
Jan 7, 2021 at 11:49 | review | Close votes | |||
Jan 11, 2021 at 0:02 | |||||
Jan 7, 2021 at 11:34 | review | Suggested edits | |||
Jan 7, 2021 at 17:40 | |||||
Jan 7, 2021 at 11:31 | comment | added | bzr | Does this answer your question? For-each over an array in JavaScript | |
Nov 28, 2020 at 0:05 | answer | added | TheComputerWizard | timeline score: 9 | |
Sep 21, 2020 at 15:42 | answer | added | kabirbaidhya | timeline score: 6 | |
Aug 24, 2020 at 17:55 | review | Suggested edits | |||
Aug 24, 2020 at 20:40 | |||||
Dec 19, 2019 at 6:40 | answer | added | Kamil Kiełczewski | timeline score: 21 | |
Aug 15, 2019 at 0:50 | answer | added | Sapphire_Brick | timeline score: 10 | |
Oct 9, 2018 at 13:17 | answer | added | Shijo Rs | timeline score: 2 | |
Oct 5, 2018 at 15:59 | comment | added | jpmc26 |
@CMS No, it's not really simple. It's really simple in every other language. It's ridiculously complex in JS, where you have in and of that can both be used and do different things. Then you also have forEach and the ugly and annoying index based looping. Every other modern language makes looping over a collection easy and straightforward with no surprises or confusion. JS could, too, but it doesn't.
|
|
Aug 29, 2018 at 0:53 | comment | added | Roobie Nuby | @EscapeNetscape the link has changed and is now jsben.ch/Q9oD5. To summarize, sequential for loop takes 60% of the time that for-in takes. | |
Aug 20, 2018 at 23:36 | answer | added | colxi | timeline score: 27 | |
May 1, 2018 at 10:17 | history | edited | John Slegers |
edited tags
|
|
Feb 23, 2018 at 11:29 | answer | added | Yuci | timeline score: 39 | |
Sep 13, 2017 at 22:11 | answer | added | BILAL AHMAD | timeline score: 6 | |
Sep 2, 2017 at 20:35 | answer | added | Andrii Starusiev | timeline score: 7 | |
Jun 9, 2017 at 18:29 | review | Suggested edits | |||
Jun 9, 2017 at 20:47 | |||||
May 27, 2017 at 2:57 | answer | added | Alireza | timeline score: 37 | |
Nov 3, 2016 at 19:45 | comment | added | EscapeNetscape | jsben.ch/#/Q9oD5 <= Here a benchmark of a bunch of solutions for looping through arrays | |
Oct 26, 2016 at 8:51 | answer | added | Espen | timeline score: 13 | |
Oct 14, 2016 at 10:31 | answer | added | Alongkorn | timeline score: 13 | |
Oct 8, 2016 at 12:17 | comment | added | Hamed Mahmoudkhani |
Also : myStringArray.forEach(function(value, index){ console.log(index, value) }); and result will be 0 "Hello" 1 "World"
|
|
Sep 20, 2016 at 6:29 | history | edited | Landys | CC BY-SA 3.0 |
edited body
|
Aug 1, 2016 at 21:18 | answer | added | bzim | timeline score: 28 | |
Jul 2, 2016 at 19:58 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
Second iteration.
|
May 26, 2016 at 19:11 | answer | added | Dan Chill | timeline score: 4 | |
Apr 29, 2016 at 9:05 | answer | added | Amit Jamwal | timeline score: 9 | |
Apr 21, 2016 at 16:03 | answer | added | Shubham Khatri | timeline score: 14 | |
Mar 31, 2016 at 11:28 | answer | added | user6139250 | timeline score: 4 | |
Mar 30, 2016 at 2:37 | answer | added | red-o-alf | timeline score: 12 | |
Mar 17, 2016 at 10:13 | answer | added | Juanjo Salvador | timeline score: 9 | |
Feb 29, 2016 at 18:56 | answer | added | John Slegers | timeline score: 84 | |
Dec 18, 2015 at 10:09 | comment | added | alex | related - stackoverflow.com/q/6208964/31671 | |
Dec 12, 2015 at 3:11 | answer | added | Daniel K. | timeline score: 8 | |
Jun 8, 2015 at 1:36 | review | Suggested edits | |||
Jun 8, 2015 at 1:58 | |||||
Oct 21, 2014 at 7:32 | answer | added | Joter | timeline score: 11 | |
Jul 23, 2014 at 12:59 | answer | added | RizN81 | timeline score: 29 | |
May 9, 2014 at 14:21 | answer | added | Sambhav Sharma | timeline score: 4 | |
Mar 17, 2014 at 2:31 | history | protected | Josh Crozier | ||
Mar 8, 2014 at 2:06 | answer | added | molokoloco | timeline score: 15 | |
Jan 11, 2014 at 20:53 | answer | added | Zaheer Ahmed | timeline score: 14 | |
Aug 11, 2013 at 15:54 | answer | added | Marlon Bernardes | timeline score: 143 | |
Aug 10, 2013 at 8:18 | history | edited | Peter Mortensen | CC BY-SA 3.0 |
Copy edited.
|
Aug 6, 2013 at 8:03 | answer | added | staticd | timeline score: 9 | |
Apr 4, 2013 at 18:37 | review | Close votes | |||
Apr 4, 2013 at 21:48 | |||||
Feb 28, 2013 at 13:59 | answer | added | Stijn de Witt | timeline score: 21 | |
Oct 21, 2012 at 6:20 | answer | added | justingordon | timeline score: 21 | |
Jun 4, 2012 at 16:26 | answer | added | Phrogz | timeline score: 41 | |
Apr 18, 2012 at 15:39 | history | notice removed | Kzqai | ||
Apr 18, 2012 at 15:39 | history | bounty ended | Kzqai | ||
Apr 18, 2012 at 14:46 | answer | added | Muhammad Alvin | timeline score: 12 | |
Apr 16, 2012 at 23:33 | answer | added | Andrew Thomson | timeline score: 28 | |
Apr 16, 2012 at 2:03 | answer | added | Mark Reed | timeline score: 1205 | |
Apr 15, 2012 at 12:50 | answer | added | kirilloid | timeline score: 18 | |
Apr 12, 2012 at 12:52 | history | notice added | Kzqai | Canonical answer required | |
Apr 12, 2012 at 12:52 | history | bounty started | Kzqai | ||
Jan 6, 2012 at 18:53 | vote | accept | Mark Szymanski | ||
Jan 5, 2012 at 9:15 | answer | added | Timo Huovinen | timeline score: 69 | |
Nov 1, 2011 at 17:53 | comment | added | jondavidjohn | related - stackoverflow.com/questions/5349425/… | |
Oct 14, 2011 at 2:33 | history | edited | Michael Haren |
edited tags
|
|
May 16, 2011 at 22:52 | answer | added | Gabriel | timeline score: 30 | |
Dec 7, 2010 at 7:24 | answer | added | sebarmeli | timeline score: 132 | |
Jun 10, 2010 at 2:43 | answer | added | kennebec | timeline score: 94 | |
S Jun 10, 2010 at 2:41 | vote | accept | Mark Szymanski | ||
Jan 6, 2012 at 18:53 | |||||
Jun 10, 2010 at 0:38 | comment | added | Christian C. Salvadó |
no, it's really simple, array objects have numeric indexes, so you want to iterate over those indexes in the numeric order, a sequential loop ensures that, the enhanced for-in loop enumerates object properties, without an specific order, and it also enumerates inherited properties... for iterating over arrays sequential loops are always recommended...
|
|
Jun 10, 2010 at 0:21 | vote | accept | Mark Szymanski | ||
S Jun 10, 2010 at 2:41 | |||||
Jun 10, 2010 at 0:15 | comment | added | Mark Szymanski | Ok, so I'm a bit confused, it's ok to use the enhanced for loop when you are accessing the objects? And use a sequential one for filling one? Is this correct? | |
Jun 10, 2010 at 0:09 | answer | added | hasen | timeline score: 453 | |
Jun 10, 2010 at 0:07 | answer | added | Christian C. Salvadó | timeline score: 5211 | |
Jun 10, 2010 at 0:04 | history | asked | Mark Szymanski | CC BY-SA 2.5 |