No, the correct way is to use the global function isNaN(x);
Function('return -0+"12"').toString();
Returns: "function anonymous() { return "012";}"
So there is no conversion going on in the test, it just returns the string "012". No wonder that it is fast. See my comment above for another jsperf where it is converted in each test. Function('return ~~(1 * "12");').toString();
And you get this result: "function anonymous() { return 12; }"
Notice that the expression has been converted to 12 in the function, so each call to it will just return 12 instead of converting it. That's why it is so much faster. The same is true for "<<", ">>" and "1 * '12'"