jashkenas/underscore — pull request #1795 by charlierudolph (2014-08-20 23:36:13+00:00)
Title: Toggle function

A simple toggling function.
Pass in the current value and an array of length 2 that you want the value to toggle between.
It outputs the toggled value.

Inspired by the following expression
```javascript
if (value === 'desc') {
value = 'asc';
} else {
value = 'desc';
}
```
A simple toggling of a variable but it requires 'desc' to be repeated twice.
Even if 'asc' and 'desc' are in constants, the constant will still need to be repeated.
With this toggle function, the expression can become
```javascript
value = _.toggle(value, ['desc', 'asc'])
```