documentcloud/underscore — pull request #830 by TalAter (2012-10-20 18:19:44+00:00)
Title: Updated _.isFinite to match ES5 and ES6 spec

The EcmaScript 5 and 6 specs define isFinite as returning false only if ToNumber(object) is NaN, Infinity or -Infinity (a very short and clear read: http://es5.github.com/#x15.1.2.5)

The current implementation of _.isFinite acts as if ToNumber('42') === NaN, and returns false on _.isFinite('42').

This was originally [done to combat an "issue"](https://github.com/documentcloud/underscore/pull/524#issuecomment-4695186) with EcmaScript's ToNumber, which returns true for empty strings (or strings full of nothing but spaces). The problem is that the fix was overzealous, and negates all argument coercion - which is the very heart of isFinite - and acts exactly the opposite of the spec and of the browsers' implementation.

This commit fixes it, while also catching the special gotcha in the spec for empty strings.

```javascript
// before :
isFinite('12') !== _.isFinite('12') // true !== false
// now:
isFinite('12') === _.isFinite('12') // true === true
// didn't change:
isFinite('') !== _.isFinite('') // true !== false
```

It's also much faster than the current implementation.