Thanks to Jordan Liggitt for passing on some videos on JavaScript by Douglas Crockford who is a senior JavaScript architect at Yahoo! The first series is pretty basic, but if you’re new to the language, it’s a very good introduction. Here are some random items I thought were noteworthy:
- Brendan Eich at Netscape originally wanted to make a dialect of Scheme, but his manager said that people wouldn’t accept “all those parentheses”, and he should make something with a friendlier syntax. Too bad, I would love to able to program Scheme in the browser
- Brendan did sneak in lambda though, he just didn’t call it that :)
- No separate character type, just strings of length 1
- == and != do type coercion; === and !== do not
- bitwise operators convert to a 32 bit signed integer and then back to a 64 bit float, so don’t use them for efficiency like you might in C
- don’t use the with statement
- be careful with for (var name in object) due to iteration of inherited members also
- blocks don’t have scope, only functions do
- vars are implicitly global if not declared
-
4 ways to call a function
- functionObject(args)
- thisObject.methodName(args)
thisObject["methodName"](args) - new functionObject(args)
- functionObject.apply(thisObject[, args])
- don’t use eval except for trusted JSON
- http://www.JSLint.com a tool Crockford wrote
- Semicolon insertion: when the compiler sees an error, it attempts to replace a nearby linefeed with a semicolon and try again! Always use the full correct form including semicolon. This was a surprise to me because once I discovered semicolons were optional, I stopped using them for a cleaner look. Oops.
The JavaScript Programming Language Part 1 of 4
The JavaScript Programming Language Part 2 of 4
The JavaScript Programming Language Part 3 of 4
The JavaScript Programming Language part 4 of 4
I’ll post another entry after I go through Crockford’s advanced series.
Tags: javascript, programming

Add a comment
Comments feed for this article
Trackback link: http://lojic.com/blog/2007/05/17/douglas-crockford-javascript/trackback/