rmurphey/js-assessment-answers — pull request #20 by MattSurabian (2013-12-05 02:11:15+00:00)
Title: Faster duplicate finder

Instead of needing to check an object for a calculated occurrence count we can check if the first index matches the last index of a given value. Though I suppose there could be a cross browser issue here as lastIndexOf isn't supported by IE 8 and below. Maybe lastIndexOf could be another test function if that's a concern :-p

When I first saw the current answer I expected it to be faster given the number of times the proposed change set calls indexOf. [Ran a JSPerf test](http://jsperf.com/duplicate-array-method-test) on it and found the opposite is true so I figured I'd submit a PR.