Prev: Standalone .js file creates IE, and call javascript functions in the page
Next: Javascript pause or sleep thread execution
From: Thomas 'PointedEars' Lahn on 14 Dec 2009 20:49 Jorge wrote: > Thomas 'PointedEars' Lahn wrote: >> Austin Matzko wrote: >> > Thomas 'PointedEars' Lahn wrote: >> >> >> e = e || window.event; >> >> >> >> Reasonable people use an `if' statement here instead. >> > >> > Would you please elaborate? I'm curious why an "if" statement would >> > be better. >> >> It saves one needless evaluation step, and because it allows for a block >> statement it allows for a finer control, including proper >> feature-testing. > > !e && (e= window.event); That is hardly better readable or more efficient than if (!e) { e = window.event; } and there is still the lack of proper feature-testing. While you could do that in an expression, too, it would become quite a mess very quickly. PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann |