Created
March 6, 2013 18:52
-
-
Save inkdeep/5101971 to your computer and use it in GitHub Desktop.
Revisions
-
inkdeep created this gist
Mar 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ // Native JS (fast) uniq = function( /* Array */ arr) { var test = {}; var result = []; for (var i = 0, len = arr.length; i < len; i++) { if (!test[arr[i]]) { // value not seen yet? test[arr[i]] = true; result.push(arr[i]); } } return result; }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ // Uses dojo (not as fast) uniq = function(/* Array */ arr){ var test = {}; return dojo.filter(arr, function(val){ return test[val] ? false : (test[val] = true); }); };