News for hackers. Stuff that matters.
Re:No ifs...alternatives to statement branching in JavaScript by planckscnst on Friday August 06, 2010 @08:48PM (#1582799)
Doesn't this depend on strict lazy evaluation? I could imagine if the implementation underneath changed (possibly to take advantage of parallel execution), if any segment had side effects, it would be horrible.
Re:No ifs...alternatives to statement branching in JavaScript by RodgerTheGreat on Saturday August 07, 2010 @12:19AM (#1583046)
I think you're confusing lazy evaluation with operator short-circuiting. (http://en.wikipedia.org/wiki/Short-circuit_evaluation)
Re:No ifs...alternatives to statement branching in JavaScript by lygaret on Friday August 06, 2010 @10:38PM (#1582946)
I can't think of a case where lazy evaluation would be required, only that the semantics of the && and || operators not change.

It's defined as part of the language that && will not evaluate the right hand side unless the left hand side is truthy. A lot more than using this stuff as branching would break if some implementation arbitrarily decided to not follow that anymore.

Re:No ifs...alternatives to statement branching in JavaScript by thienan on Friday August 06, 2010 @11:40PM (#1583017)
Thanks