bloodyowl / craft

[DEPRECATED]
110 stars 6 forks source link

Avoid `Object.typeOf` method when not necessary #5

Closed jdalton closed 11 years ago

jdalton commented 11 years ago

I noticed in a few places you use the Object.typeOf function to check things like undefined or function and you could simply use the typeof operator instead.

Also you might tweak the method to use var toString = {}.toString and check toString.call(value) == '[object RegExp]', it follows spec a bit more closely as with Array.isArray which is crazy fast too.

bloodyowl commented 11 years ago

I use the local typeOf function to make it easier to minify. Also it looks like that an instanceof check is quite faster that a call of the {}.toString.

jdalton commented 11 years ago

I use the local typeOf function to make it easier to minify.

Gzip will handle a lot of that.

Also it looks like that an instanceof check is quite faster that a call of the {}.toString.

Yap for sure, it's a balance of compliance vs common use. The toString.call() will work cross-iframe and follows spec more closely, but it's up to you to frame your support.

bloodyowl commented 11 years ago

I keep this in mind for a next update. ;)