> From: Pops > > I always had been taken a back by the erroneoous usage of the term > "ternary condition" for the ? operator. The ? is called the > Conditional Operator and it provides binary logic. By > definition, Ternary is three, not two. Binary provides a > true or false execution path. A ternary path is true, false > or "maybe" which is normally called Fuzzy Logic.
It's called a ternary operator because it takes three arguments, just as a binary operator takes two arguments and a unary operator one. http://foldoc.org/?ternary Ternary: A description of an operator taking three arguments. The only common example is C's ?: operator which is used in the form "CONDITION ? EXP1 : EXP2" and returns EXP1 if CONDITION is true else EXP2." I agree, "conditional operator" is a much better name because it describes what it *does*, but it's too late to fight this one. :-) > Also, in the paragraph discussing: > > condition == true ? foo() && bar() && something() :0; > > where Pauls says "While we would need all three functions to > execute, the parser only executes until one of the functions > returns false..." > > This is normally called "Short Circuiting Logic." That's true. Also, it's not the parser that does the short circuiting. The parser always parses the entire JavaScript source code (unless there's a syntax error). That's compile time. Short circuiting, like all operator evaluation, happens at runtime. > I am curious to refreshing my mind if the JS intepreter > short circuits & bit masking. In other words: > > fn(a) & fn(b) > > I have to check that out. I guess it depends on the compiler > or intepreter. It's pretty rare for anything like this to depend on the compiler or interpeter. Operator semantics are a pretty basic part of the core JavaScript language, and you should be able to count on that expression working the same in any JavaScript implementation. It's not like the DOM, where every browser does it according to its own whim. -Mike