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...
2957
Daniel
dmorilha
Aug 2, 2012 1:34 am
In the case I repeat the same identifier on a catch block I receive an "'identifier' is already defined" error message. try { } catch (exception) { } ... try {...
2958
Tom Worster
thefsb
Aug 8, 2012 12:46 am
Some compressors do not touch the initial comments of a file in order to leave copyright, license etc. in place. I find that useful. However, some of my files...
2959
aceblchboy
Aug 8, 2012 1:27 pm
... I believe the goal of this rule is to make it easier to identify exactly where the error is happening, and there's no shame in numbering. I also prefix...
2960
douglascrockford
douglascrock...
Aug 8, 2012 1:28 pm
... Could you be more sepecific?...
2961
Tom Worster
thefsb
Aug 8, 2012 1:53 pm
... Sure. I'd like to have a source code file that begins like this: /* Public copyright notice not to be compressed */ ; /* Code comments the compressor...
2962
Jakob Kruse
thekrucible
Aug 8, 2012 2:11 pm
This is very compressor specific, is it not? Both comments would be removed (regardless of your choice of snippet) by JSMin and YUI Compressor for instance,...