Lojic Technologies

Douglas Crockford: JavaScript

leave a comment »

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

    1. functionObject(args)
    2. thisObject.methodName(args)
    3. new functionObject(args)
    4. 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.

Written by Brian Adkins

May 17, 2007 at 3:26 pm

Posted in programming, video

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: