I saw this code on the Internet:
function MyEventHandler(e) { var ev = e || event; var target = ev.srcElement || ev.target }
In essence, the operator || used as an abbreviation for a?a:b . As far as I can tell, it works in all browsers. But, bringing up the specifications of, say, JScript, I see :
Performs a logical disjunction in two expressions.
and
JScript uses the following rules to convert non-Boolean values ββto Boolean values:
- All objects are considered true.
So ... according to this result there should be a boolean true / false. I'm just wondering: am I walking along a knife of undocumented behavior, or are there any subtle consequences here that I did not take?
Vilx- source share