JSLint Reports on last 2 Production Versions of jQuery

A

Andrea Giammarchi

If you're checking for '=== null' 99% of the time, then
write '=== null' 99% of the time. What is boring is
debugging code whose intent has not been made clear by the
author. --Antony

I am checking to know if it is undefined or null so I use the "==
null" check 'cause I don't want to set null properties in any
prototype, it's absolutely pointless.
Back at the beginning, it is boring to write every time that I meant
it via code.
If you don't know == null means === undefined || === null it cannot be
other devs fault.
We are coder, not monkeys unable to understand basis of the
programming language we use on daily basis, the problem is somewhere
else in this case, imho.
 
D

David Mark

Andrea said:
I am checking to know if it is undefined or null so I use the "==
null" check 'cause I don't want to set null properties in any
prototype, it's absolutely pointless.

Then why are you checking for null? That's the point. Your code is
ambiguous and the next person reading it can't be expected to read your
mind, so will have to investigate to determine exactly what you meant
(or did not mean).
Back at the beginning, it is boring to write every time that I meant
it via code.

What does that mean?
If you don't know == null means === undefined || === null it cannot be
other devs fault.

That's not the point. I know what it means, but I can't guess what
_you_ thought it meant. If I find, after investigation, that you were
using == null when === undefined would have sufficed, I'd have to wonder
what you were thinking (and I don't want to have to wonder about what
you were thinking).
We are coder, not monkeys

Some of us. :)
unable to understand basis of the
programming language we use on daily basis, the problem is somewhere
else in this case, imho.

You have got the wrong end of the stick (again).
 
A

Andrea Giammarchi

Then why are you checking for null?  That's the point.

again, to know if a variable is null or undefined since I threat both
values as one, I've never had a valid reason for distinguish between
null and undefined.

 Your code is
ambiguous and the next person reading it can't be expected to read your
mind, so will have to investigate to determine exactly what you meant
(or did not mean).

since you'll never find a === undefined in my code, I wonder wchih
part is ambiguous...

What does that mean?

typo, I meant every time I have to specify via *comment* that I meant
it ...

That's not the point.  I know what it means, but I can't guess what
_you_ thought it meant.  If I find, after investigation, that you were
using == null when === undefined would have sufficed

there we are ...
=== undefined is a disaster prone approach. Nobody should rely in a
global scope variable as undefined is to understand if a variable is
undefined.
typeof varname === "undefined" is the only safe way, OR we can simply
test against == null if we are NOT interested into undefined values.

You have got the wrong end of the stick (again).

while apparently You have not get what is the problem and why ...

Again, and for the last time:

1 - there is no coercion against "== null" , only a case specified by
specs
2 - "== null" is true only with null or undefined, the error showed
by JSLint and the privded reason (coercion) *is* *wrong*
3 - I do believe undefined is a "pointless value" on daily basis
code, I rarely need to know if a value is exactly undefined ... the
most common case is *double* check against null and typeof "undefined"
indeed and this is a waste of time, a waste of bytes, a waste of
performances ... but surely you decide how to code in a "non ambiguous
way" for a case that has nothing ambiguous for its purpose, imho

Regards
 
D

David Mark

Andrea said:
again, to know if a variable is null or undefined since I threat both
values as one,

And therein lies the rub.
I've never had a valid reason for distinguish between
null and undefined.

Unfortunately, the rest of the JS world, including host objects
disagrees with your assessment of the two values. Therefore, your code
is unintelligible to others.
since you'll never find a === undefined in my code, I wonder wchih
part is ambiguous...

The part that is not === undefined, of course. In other words the ==
null parts.
typo, I meant every time I have to specify via *comment* that I meant
it ...



there we are ...
=== undefined is a disaster prone approach. Nobody should rely in a
global scope variable as undefined is to understand if a variable is
undefined.

That's beside the point. Use typeof xyz == 'undefined' if you are
worried about the global undefined being stepped on (or compatibility
issues that can arise in ancient browsers).
typeof varname === "undefined" is the only safe way, OR we can simply
test against == null if we are NOT interested into undefined values.

Those two are not equivalent, hence the ambiguity.
while apparently You have not get what is the problem and why ...

[...]

No, I get what the problem is. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top