Domain: jslint.com
Stories and comments across the archive that link to jslint.com.
Comments · 8
-
Re:Javascript is a disaster
No scope to speak of
well, it's not true really. In the following example x will have global scope and y will be local to its function:
x=2; function test() { y = x + 3; }
Have to correct you here: In JavaScript, ALL variables that are not explicitly declared with var are declared global. It's without question the worst "feature" of JavaScript. In your example, both x and y are global. The correct example code is:
x = 2; function test() { var y = x + 3; }
However, like almost all problems with JavaScript, running your scripts through Douglas Crockford's JSLint (and strictly adhering to it) pretty much eliminates that issue. It can be run on the command line as part of a build script, and has really helped me write much better JS code.
-
Re:Javascript is actually a great language
http://www.jslint.com/ or http://developer.yahoo.com/yui/compressor/ (with -v set) will pick up these types of bugs (in lieu of a compiler).
-
Re:Java != Javascript
In JS, it's "not identical". It means "don't try to do any implicit casting - not only must their values be the same, but their type must be the same too"
I get pinged on it all the time when I'm running other people's JS through http://www.jslint.com/
-
Great book - try out the online 'debugger'
I really like this book. The author does not treat you like an idiot or make 'oh so funny' jokes to make you feel comfortable with the text. The writing style is friendly and fluid, while the content is always to point. I wish more programming books were as dross-free as this one.
Many readers are likely to read through sections twice or a few times. Crockford warns, 'This book is small, but it is dense', and it is certainly is cramed with useful information. The author states no intention of writing a JavaScript reference but has certainly written a book that I will pick up frequently on JavaScript projects
I am surprised the reviewer didn't mention JSlint a free, online JavaScript 'verifier', written by the author, that can be used to 'debug' and write better code. It may even be worth a try before you buy the book.
-
Re:Scoping is Awful? You need to buy the book...
If you would read the book you would find that your code contains a few definite "don't do that, that is bad practice" statements (at least according to Crockford).
If we take away the fact that there are several global variables created, the most problematic thing is that the code creates "elements.length" number of functions -> memory consuming, when it is easy to avoid.
There are several videos on YDN theatre which discuss many of the subjects the reviewer mentions (these screencasts came before the book). After I watched one I ended up watching just about all of them. See and listen to http://developer.yahoo.net/blogs/theater/archives/douglas_crockford/
and you will start to understanding javascript... not just write stuff what seems to work.
If you want to see if you write "good" javascript try "jslint" written by Crockford http://www.jslint.com/ But like the site says "WARNING: JSLint may hurt your feelings."
-
Re:Back when people could actually code..
The great irony is that all the things that made LISP useful in the 50's now make it a near perfect language for today. Great abstraction, objects, super efficient compiled code, libraries. And yet
...
And yet ... a large chunk of those benefits are available in languages with a syntax much closer to C, and those languages are cleaning up. Ruby, Python, Javascript. Personally though, I'm starting to build programs in Javascript that coincidentally have a web-UI, simply because of tools like JSLint, and great libraries like Prototype (think doing Haskelly stuff in Javascript) and jQuery (think Web 2.0 without the pain). -
Re:This is what lost the browser wars
You might want to try JSLint(documentation) by Douglas Crockford. It checks that variables are defined before use, and also checks for other common mistakes (you can read about them in the documentation).
-
Re:This is what lost the browser wars
You might want to try JSLint(documentation) by Douglas Crockford. It checks that variables are defined before use, and also checks for other common mistakes (you can read about them in the documentation).