T
Thomas 'PointedEars' Lahn
beegee said:Yes, I agree completely. Unfortunately, at my shop, we have tons on
ASP pages ('mixin' of server-side VBScript and client-side JScript)
where not one semicolon can be found.
Non sequitur. ASP is an (IIS-based) application framework that supports
both VBScript and JScript, among other programming languages. In VBScript,
a semicolon is a syntax error, and there are no braces.
However, now that we've decided that {} should always be used, we need
to decide where. Should the opening curly bracket be on the same line
as the conditional,function etc. or on the next line?
A matter of taste and teamwork.
if (blah) {
}
or
if (blah)
{
}
The readability of the second case is considered superior, however in
some cases it can cause program errors. As Crockford points out in
"Javascript: The Good Parts",
return
{
status: true
};
returns undefined, whereas
return {
status: true
};
returns true.
You (and Douglas) would need to recognize the difference between a block
statement and an Object initializer; here, the latter is meant (else it
would be a syntax error). Writing the braces for the former on their own
line always, and for the latter not, helps to see that difference. This is
also how I recommend to make the difference between function statements and
function expressions:
function foo()
{
// ...
}
but
var bar = function baz() {
// ...
};
foobar(
/x/,
function baz() {
// ...
});
HTH
PointedEars