Thanks for clearing that up John.
-Trey
On Feb 19, 10:07 am, John Resig wrote:
> > Why implement jQuery.isFunction when you can also just go typeof
> > variable == 'function'?
>
> You can see some of the cases that we handle that normal typeof can't,
> here:http://dev.jquery.com/browser/trun
> I'm curious what the benefit of that would be. Given that the
> window.undefined property exists and has the undefined value, I'd think they
> would give the same result.
They give the same results for properties, at least:
someObject.undefinedProperty === undefined
but not for variables th
I'm curious what the benefit of that would be. Given that the
window.undefined property exists and has the undefined value, I'd think they
would give the same result.
-Mike
> From: John Resig
>
> ...we'll probably switch from foo === undefined
> to typeof foo === "undefined" - we'll see
On Feb 18, 2:53 pm, pbcomm wrote:
> This might be a stupid question, but I have to ask ...
> What is the reason for not having functions like isString, isNumber,
> isBoolean, etc? Is it just because that would create extra function
> calls?
The simple reason for me is that typeof tells you the
lol, i can see this kind of took a different route ;) thank you all
for replying ;)
On Feb 18, 6:25 pm, John Resig wrote:
> > Safari: +3ms, +2ms, +7ms, +3ms, +4ms
> > Opera: +46ms, +35ms, +21ms, +19ms, +36ms
>
> I forgot to mention that this means that == is about 10% slower than
> === in both b
> Safari: +3ms, +2ms, +7ms, +3ms, +4ms
> Opera: +46ms, +35ms, +21ms, +19ms, +36ms
I forgot to mention that this means that == is about 10% slower than
=== in both browsers.
--John
> Why implement jQuery.isFunction when you can also just go typeof
> variable == 'function'?
You can see some of the cases that we handle that normal typeof can't, here:
http://dev.jquery.com/browser/trunk/jquery/test/unit/core.js#L176
--John
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)
Why implement jQuery.isFunction when you can also just go typeof
variable == 'function'?
-T
On Feb 19, 7:54 am, Kean wrote:
> Seems like my hunch is incorrect, thanks for correcting.
>
> On Feb 18, 12:43 pm, Matt Kruse wrote:
>
> > On Feb 18, 2:20 pm, Kean wrote:
>
> > > While it would not
Seems like my hunch is incorrect, thanks for correcting.
On Feb 18, 12:43 pm, Matt Kruse wrote:
> On Feb 18, 2:20 pm, Kean 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 betwe
On Feb 18, 2:20 pm, Kean 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 q
Matt,
While it would not affect the results, I believe you can shave a few
ms off by using ===
On Feb 18, 11:26 am, Matt Kruse wrote:
> On Feb 18, 6:57 am, John Resig wrote:
>
> > typeof FOO === "string"
> > typeof FOO === "number"
> > typeof FOO === "boolean"
>
> == is sufficient. typeof alw
On Feb 18, 6:57 am, John Resig wrote:
> typeof FOO === "string"
> typeof FOO === "number"
> typeof FOO === "boolean"
== is sufficient. typeof always returns a string.
Matt Kruse
Date: 02/18/2009 08:36 AM
Subject:[jQuery] Re: A question for John Resig
> I know they are there and I've used added functions to save on the
> code size,
> I know they are there and I've used added functions to save on the
> code size, which makes a big difference when used a lot.
It doesn't make any difference save for a few characters.
I know they are there and I've used added functions to save on the
code size, which makes a big difference when used a lot. That's why I
wanted to see if there are some other drawbacks I was not aware of.
On Feb 18, 7:57 am, John Resig wrote:
> Extra function calls sure - plus there's really no
Extra function calls sure - plus there's really no need for those
methods, they're already a part of JavaScript.
typeof FOO === "string"
typeof FOO === "number"
typeof FOO === "boolean"
--John
On Tue, Feb 17, 2009 at 11:53 PM, pbcomm wrote:
>
> This might be a stupid question, but I have to
17 matches
Mail list logo