.
JS & Unicycles - Grin with cat attached
Previous Entry Next Entry
JS & Unicycles Aug. 24th, 2007 11:26 am
Someone (apparently duncanneko, to whom many thanks) recently recommended me this:

The world's most useful JS tutorial reference (also here).

It makes my brane hurt. Then I discovered I'd been watching the beginner's tutorials.


It made it hurt even more when I discovered that the guru doing the presenting had also written this.


Having also read, and barely followed, ciphergoth's self-described rant on the subject, I am minded to suggest that v3 of most languages are borken; if you ever see v3 of a language, hope that v4 is better and v5 might just get it right.

From: duncanneko
Date: August 24th, 2007 - 11:14 am (Link)
It's okay, it gets better when you start running into behaviour that's either a deep and meaningful subtlety or a browser bug (with no way of telling the difference).

(Yes, I may be bitter about javascript at the moment)
From: wechsler
Date: August 24th, 2007 - 11:26 am (Link)
One of the small steps that can be taken to mitigate JS pain is Firebug, if you're not already using it - see http://www.getfirebug.com/ and the presentation on http://developer.yahoo.com/yui/theater/ - I've not tried Crockford's JSlint yet but it's probably also worth a try.
From: duncanneko
Date: August 24th, 2007 - 11:29 am (Link)
Use it an love it. I should probably run some of the weird code through JSLint and see what it thinks of it, actually.
From: duncanneko
Date: August 24th, 2007 - 11:37 am (Link)
And indeed, that helped, thanks for reminding me it existed.

More specifically, it told me that:
for(var i=0; i<10; i++) {
...
}
// i is still in scope at this point


Which is the opposite to Java and so what I expected >.<
From: wechsler
Date: August 24th, 2007 - 11:45 am (Link)
Yes; scope is apparently that of the outermost function at minimum. I think.
From: duncanneko
Date: August 24th, 2007 - 11:50 am (Link)
All functions (including nested/inner ones) have their own scope, but there's no scoping within functions - which I'd forgotten about completely, though it is mentioned in the lectures.
From: wechsler
Date: August 24th, 2007 - 11:54 am (Link)
OK - I was confused by slide 89 of the PPT in http://yuiblog.com/assets/crockford/javascript.zip

So yes, looks like *innermost* function scope.