- 2009-03-04 (Wed) 3:35
- JavaScript
A few times, I mentioned on my blog here, “JavaScript: The Good Parts.” The author of the book, Douglas Crockford gave a talk at Google Campus on Feb 27, 2009. You can check it out on YouTube.
The talk is very insightful. And it actually very much about what he wrote on the book. If you are interested in reading that book but haven’t got that yet, you may get at least half of his points by watching this Google TeckTalk. And also he is touching what the future of JavaScript will be. Strict mode will be interesting. And I guess it would boost the speed.
I pick up some of his points what I was interested in.
==
By his saying, JavaScript’s loosely-typed and dynamic nature has very strong potential. But == and != is not that kind of dynamics. As opposed to === and !== compares value and type of each side, == and != compares loosely.
'' == '0'; //false 0 == ''; //true 0 == '0'; // true false == 'false'; //false false == '0'; // true false == undefined; // false false == null; // false null == undefined; // true ' \t\r\n ' == 0; // true
I tried everything, and it works as he described… I thought they all convert each side of values to boolean and compare, but that doesn’t explain some lines above… (0 == '0'; false == undefined; false == null; ' \t\r\n ' == 0;) I really have to check up the spec.
Style isn’t Subjective in JS
It shouldn’t be new-lined before object literal curly bracket. The obvious failure will like this.
return
{
"foo": "bar"
};
After the first line, JS interpreter automatically insert ;(semicolon) after “return”, so it returns always undefined.
new
I cannot agree to this one, though I understand the catastrophe. His concern is.. When you forget to add “new”, you don’t get warning. It may not give the error, but in most cases, it does give a different behavior, as far as I experienced. And plus, his loving “beget()” or “create()” method just look super awkward for prototype-chaining to me. It contaminate global space, which he also accused.
JSLint
These days, I started use Rhino a lot, in order to do debug JavaScript. Hopefully, I’ll find the best practice of build process in JavaScript but anyway. I use JSLint and JS Beautifier.
I will write how I use it with Rhino soon.. (Jeez! JS Beautifier repository now contains Rhino command..!)
Here’s the amazon link for the book.
Comments:0
Trackbacks:0
- Trackback URL for this entry
- http://blog.nydd.org/2009/03/javascript-the-good-parts-talk-available-on-google-tech-talks/trackback/
- Listed below are links to weblogs that reference
- JavaScript: The Good Parts Talk available on Google Tech Talks from Vantage Point of Queens



