Closed ljharb closed 9 years ago
fantastic, thanks for the thoroughness and updated benchmarks!
avoids a switch (those are gross)
ha, yeah I hear that. compared to the code in your pr, it certainly looks that way too lol.
of course, micro-benchmarks are silly and don't cover real world use cases
I hear that too, but I think they're better than nothing, and doing them helps me learn :) thanks for updating them. this is great!
Pushed up 2.0.0, thanks again!
This is a simpler check, a faster check, avoids a switch (those are gross), and will automatically be extensible if new "typeof" values are added in the future.
see http://jsperf.com/testing-value-is-primitive/7 - of course, micro-benchmarks are silly and don't cover real world use cases, so it's pretty irrelevant. Note that on Safari,
isPrimitive_or
is fastest, as opposed to the switch alternatives, which are way slower - and "simple" is the fastest overall, second only to the regex approach in firefox which is insanely fast because of it's weird regex implementation.