Ubiquitous conditionals

Brendan Eich brendan at mozilla.org
Wed Jan 25 13:28:08 PST 2012

Herby Vojčík wrote:
> The code above is till too imperative - it is really carrying out the 
> if statement and the doing whatever one pleases inside (so one must 
> scan if it really is only result.{...}), and has one level of nesting 
> more.
The form you showed was every bit as imperative. I don't like punning 
'if' statements into object literals as a special form.Why not switch 
statements? Why not loops with computed property names?

Restricting the consequent or loop body to be more declarative does not 
remove the ability to do a great many imperative things in the initial 
value expressions.

We have imperative forms (statements). We have object literals. Keeping 
them from blurring together is better for readability in my opinion. Add 
to this the relative rarity of needing such an if. Then add the ability 
to use .{ or whatever it'll be called.


More information about the es-discuss mailing list