News for hackers. Stuff that matters.
Re:No ifs...alternatives to statement branching in JavaScript by gruseom on Saturday August 07, 2010 @11:49AM (#1583732)
But that crashes on null in all three languages, no? (i.e. if evt is null and window.event is non-null.) I suppose you could do this:

  function getEventTarget(evt) {
    return (evt || (evt = window.event)) && (evt.target || evt.srcElement);
  }
But that's probably more trouble than it's worth. Anyway, I agree with you in preferring expressions to statements on the whole. It's hard to imagine why anyone would prefer the more than 4x as long version in the OP; to me it reads like a parody.
Re:No ifs...alternatives to statement branching in JavaScript by scott_s on Saturday August 07, 2010 @04:45PM (#1584273)
In C/C++, evt could never be null because it would have to be a stack allocated object or a reference. (We're not dereferencing a pointer.)
Re:No ifs...alternatives to statement branching in JavaScript by gruseom on Saturday August 07, 2010 @06:46PM (#1584493)
Gotcha. It's been a while!