Timeline for Finding the mode of an array
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 30, 2014 at 8:55 | comment | added | janos | @wei2912 absolutely right, and I know it, I don't know what drove me to write that... Deleted now, and asked the OP to accept Sacho's instead. | |
Oct 30, 2014 at 8:52 | history | edited | janos | CC BY-SA 3.0 |
deleted 282 characters in body
|
Oct 30, 2014 at 8:43 | comment | added | wei2912 |
In JavaScript for (var i in arr) is hugely discouraged; look at stackoverflow.com/questions/500504/… What @MT0 wrote appears to be rather contrived.
|
|
Oct 30, 2014 at 7:01 | comment | added | Sacho |
That's fairly contrived though(you wouldn't really want to set properties on your simple arrays, that would in most cases be a misuse of them). I still agree with your comment, since you can use arr.forEach(function (element) { }) , and reduce the further arr[i] usage to just element
|
|
Oct 30, 2014 at 5:22 | vote | accept | user2801122 | ||
Oct 30, 2014 at 16:06 | |||||
Oct 30, 2014 at 0:27 | comment | added | MT0 |
Using for (var i in arr) is not always a good idea. var arr = [1,2,3]; arr.test = "test"; for( var i in arr){ console.log( i, arr[i]); } will log 4 things but the array length is only 3.
|
|
Oct 29, 2014 at 23:10 | history | answered | janos | CC BY-SA 3.0 |