sbiermanlytle / iioEngine

iio Engine: A JavaScript game engine for HTML5 Canvas
http://iioengine.com
455 stars 81 forks source link

Performance: isNumber #30

Closed lcnvdl closed 10 years ago

lcnvdl commented 10 years ago

http://jsperf.com/isnumber/4

My recomendation

iio.isNumber = function (o) {
    if (typeof o === 'number')  {
        return true;
    }
    return (o - 0) == o && o.length > 0;
}
sbiermanlytle commented 10 years ago

Yes, that is much better. This implementation is now in 1.3 and 1.2