It really depends in which browser you test. I'm seeing little to no
difference in IE and Firefox - but a noticeable difference in Safari
and Opera.

http://dev.jquery.com/~john/ticket/equals/

Safari: +3ms, +2ms, +7ms, +3ms, +4ms
Opera: +46ms, +35ms, +21ms, +19ms, +36ms

(over 500,000 iterations)

It's not massive, but it's measurable.

As far is its use - I see no problem with it. It's more precise and
instills good habits (being more precise about what you want to
target).

I also see no problem with this:
if ( typeof text !== "object" && text != null )

We want items that aren't objects, aren't null, and aren't undefined.
Looks fine to me.

As far as convention, we're already working to formalize it:
http://docs.jquery.com/JQuery_Core_Style_Guidelines

It's very basic right now (and we'll probably switch from foo ===
undefined to typeof foo === "undefined" - we'll see) but it's a work
in progress.

--John



On Wed, Feb 18, 2009 at 3:43 PM, Matt Kruse <m...@thekrusefamily.com> wrote:
>
> On Feb 18, 2:20 pm, Kean <shenan...@gmail.com> wrote:
>> While it would not affect the results, I believe you can shave a few
>> ms off by using  ===
>
> Over 10,000,000 iterations, I see no difference in time between using
> == and ===.
> If the return type of 'typeof' varied, a difference might be found.
>
> It's just a minor quibble anyway. It's similar to lines like this in
> the jquery source:
>
> if ( typeof text !== "object" && text != null )
>
> Fixing things like this would tighten and improve the code a bit, IMO.
>
> Matt Kruse
>

Reply via email to