JSLint will now warn if you write typeof x === 'null' || typeof x === 'undefined39; instead of x === null || x === undefined...
2925
spence.randall@...
spence.randa...
Jul 19, 2012 4:10 pm
I foresee a minor problem with this: in most browsers, undefined is not read-only and can be overwritten, which means if you have other code on a page outside...
2926
[MACSkeptic] Mozair A...
macskeptic
Jul 19, 2012 4:26 pm
If you are concerned that undefined might be redefined, you can always wrap your code with a self invoking function, right? Something like: (function...
2927
Michael
newmaniese
Jul 19, 2012 4:29 pm
JSLint will complain if you try to redefine undefined: Read only. undefined = "foo"; On Thu, Jul 19, 2012 at 12:26 PM, [MACSkeptic] Mozair Alves do Carmo...
2928
Deva Satyam
satyamutsa
Jul 19, 2012 4:36 pm
Even if you allow multiple var declaration, JSLint stops when if finds a variable defined within a for (). The problem is not so much that it reports an issue...
2929
Rob Richardson
erobrich@...
Jul 19, 2012 5:02 pm
If I am building a library and someone stupid consumes my library and also redefines undefined in a very foolish way, and my library breaks because of it, the...
2932
spence.randall@...
spence.randa...
Jul 21, 2012 11:51 pm
I'd like to hear from Douglas as to why the change and warning, we still don't know the reason for the change, so perhaps there is something we are missing. ...
2934
aceblchboy
Jul 23, 2012 3:52 pm
Assuming that type is a MIME type and href is a URL, why is this a weird condition? matched = ((Boolean(~type.indexOf(".jpeg")) &&...
2935
douglascrockford
douglascrock...
Jul 23, 2012 4:57 pm
... typeof null is an error. typeof undefined is bigger and slower and less informative....
2936
douglascrockford
douglascrock...
Jul 23, 2012 4:58 pm
... Thanks. Please try it now....
2937
Joe Hansche
joeatrr
Jul 23, 2012 5:11 pm
... still don't know the reason for the change, so perhaps there is something we are missing. ... To clarify: see ...
2938
Joe Hansche
joeatrr
Jul 23, 2012 5:17 pm
One of the problems with this, is if the bug puts the interpreted state of the code into an inconsistent state.. Jslint might not be able to continue ...
2939
spence.randall@...
spence.randa...
Jul 23, 2012 5:17 pm
Right, typof null was never a question, that one is pretty well known to be problematic. I was more curious about typeof undefined. So typeof undefined is...
2940
douglascrockford
douglascrock...
Jul 23, 2012 6:09 pm
... Let me know when that happens....
2941
bartman1c
Jul 25, 2012 5:38 pm
How do I add the exception to this "check" both globally or in a single line of code, for example: if (typeof var === 'undefined39;) { //many lines of code here ...
2942
douglascrockford
douglascrock...
Jul 25, 2012 5:58 pm
... if (var === undefined) { } You are welcome....
2943
Jordan Harband
ljharb
Jul 25, 2012 6:27 pm
Douglas - I found http://jsperf.com/typeof-vs-undefined-check/3 awhile back which shows that `typeof foo === "undefined"` is faster in some browsers and slower...
2944
douglascrockford
douglascrock...
Jul 25, 2012 6:47 pm
... I do not recommend selecting programming features based on insignificant performance findings. ... Such a mishaps has never been reported. It is fixed in...
2945
Marcel Duran
marcelduran
Jul 25, 2012 7:14 pm
How can I avoid ReferenceError for cases like: var bar = (foo !== undefined) && foo.bar; when var bar = (typeof foo !== 'undefined39;) && foo.bar; works in this...
2946
Luke Page
page.luke...
Jul 25, 2012 7:58 pm
Be explicit about where foo is defined e.g. in the global scope var foo = foo; will not alter foo if it is already defined but will make sure the var is ...
2947
s_lubowsky
Jul 25, 2012 8:29 pm
While I don't mind the new rule, I have run into a case where the suggested replacement style code doesn't work. For example suppose we have a page that uses...
2948
douglascrockford
douglascrock...
Jul 25, 2012 8:34 pm
... Put var Foo; near the top of the second file....
2949
s_lubowsky
Jul 25, 2012 8:46 pm
OK, but now you have to wonder if this is an improvement. The old code would have worked as is, the new code will fail unless the developer remembered to add...
2950
Luke Page
page.luke...
Jul 25, 2012 9:26 pm
The 'extra code' makes it safer as you'll never get a reference error and it makes your dependencies clearer. ... [Non-text portions of this message have been...
2951
s_lubowsky
Jul 25, 2012 9:48 pm
But the old way is safer in that it wont blow up in my clients face if I forget to add a useless declaration of a variable defined by someone else in a...
2952
Luke Page
page.luke...
Jul 25, 2012 9:53 pm
Jslint does warn you unless you told jslint it was a global... ... [Non-text portions of this message have been removed]...
2953
s_lubowsky
Jul 25, 2012 9:58 pm
Which if course I did, since it is defined in another file. I guess the lesson here is that rather then telling jslint that things are global you should simply...
2954
firstbakingbook
Jul 27, 2012 11:30 pm
Is there a simple method that jslint would be happy with for removing all matching substrings like str.replace(/#[^\n]*/g, '') (cutting all text starting with...
2955
firstbakingbook
Jul 27, 2012 11:35 pm
I see on other forums that people use jslint comments to change the settings for portions of a file, like /*jslint something: true */ ...
2956
douglascrockford
douglascrock...
Jul 28, 2012 12:36 am
... The directives are treated as statements, so they can go where statements can go. They respect block scope, so if you turn something on in a block, you...