jashkenas/underscore — pull request #1758 by megawac (2014-07-21 21:33:56+00:00)
Title: Add _.slice function

Add a slice function with the python contract `_.slice(collection, start, end, step)`

See https://docs.python.org/2/library/functions.html#slice. Like python slice, it doesn't do any coercing of inputs (besides 0 which is coerced to 1). Python will give an error for invalid inputs, this implementation doesn't bother and carries on. One nice benefit of the step feature is now we can do non destructive reversing `_.slice(arr, null, null, -1)`

Created some jsperf benchmarks the other day http://jsperf.com/cr-52768