my rue of thumb is: I use {} whenever i use a line break. when i can keep
things in one line i find it more readable:
if (check == true) return;
if (check == false){
//some more complex logic
}
also, whenever nesting other if statements.
this way i don't miss any line break and misinterpretations.
-----------
אריה גלזר
052-5348-561
5561
On Sat, Feb 20, 2010 at 23:32, Trevor Orr <[email protected]> wrote:
> This not a MooTools but just a general JavaScript question.
>
> I was just curious about the usage of the { in if statements.
>
> Given the 2 blocks below:
>
> if (variable == 'value')
> doonestatement;
>
> OR
>
> if (variable == 'value') {
> doonestatement;
> }
>
> Is there any benefit to putting the { around the statement to execute if
> there is only one statement to execute? I have seen code both ways, where
> there is never a { if there is only one statement and code where there is a
> { no matter how many statements there are to execute after an if statement.
>
> Is it just a matter of personal preference or does it provide a speed
> performance or is there other reasons?
>
>
>
>