jacktrades/array_lib — Issue #2: Allow === comparisons in search functions
Author: jacktrades
Created: 2011-12-15 22:15:53+00:00
State: open

Currently most of the search functions use an anonymous function as the predicate to determine if an element is found. This provides a lot of flexibility, however the application of an anonymous function over a large array can be a bottleneck, especially in many cases where the anonymous function is simply testing for equality. For example:

find(function (x) { return x === 42; }, [7, 21, ..., 42])

This would be both clearer and faster written as:

find(42, [7, 21, ..., 42])

In these cases === should be used as the predicate.