Timeline for Comparing two arrays to see if they contain objects with different IDs
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 11, 2015 at 8:44 | answer | added | Neil | timeline score: 1 | |
Feb 22, 2012 at 17:38 | history | tweeted | twitter.com/#!/StackCodeReview/status/172374640721797120 | ||
Feb 22, 2012 at 16:19 | history | edited | Domenic | CC BY-SA 3.0 |
added 92 characters in body
|
Feb 22, 2012 at 16:18 | vote | accept | Domenic | ||
Feb 22, 2012 at 15:35 | comment | added | Gerben |
@Domenic I see. In that case !== should be < :-P
|
|
Feb 22, 2012 at 15:17 | comment | added | Quentin Pradet | Consider adding Array.prototype.compare too. :) | |
Feb 22, 2012 at 13:34 | vote | accept | Domenic | ||
Feb 22, 2012 at 13:34 | |||||
Feb 22, 2012 at 13:34 | comment | added | Domenic |
@Gerben consider idsA = ["x"] , idsB = ["x", "y"] .
|
|
Feb 22, 2012 at 12:20 | comment | added | Gerben | I would remove the .length comparison code. The for loop below it, would give the same result. The only reason for putting it there would be performance. | |
Feb 22, 2012 at 11:02 | answer | added | Quentin Pradet | timeline score: 3 | |
Feb 22, 2012 at 5:37 | comment | added | Leonid |
In general you want to name it containSameIds and just swap return true with return false . I personally would convert arrays to hash sets and then iterate over one, then another (if sizes are the same). I would not try to make the function too short at the expense of readability.
|
|
Feb 22, 2012 at 3:32 | history | edited | Domenic | CC BY-SA 3.0 |
added 52 characters in body
|
Feb 22, 2012 at 3:01 | answer | added | Ross Patterson | timeline score: 1 | |
Feb 21, 2012 at 21:53 | answer | added | Gerben | timeline score: 12 | |
Feb 21, 2012 at 19:57 | history | asked | Domenic | CC BY-SA 3.0 |