niche Posted August 16, 2012 Share Posted August 16, 2012 (edited) I can't find a ref for the double question marks. document.getElementById('cursorY').value = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);} Do you have one? Edited August 16, 2012 by niche Link to comment Share on other sites More sharing options...
justsomeguy Posted August 16, 2012 Share Posted August 16, 2012 That's 2 ternary operators, not a "double question mark". There's no "??" operator, that is a pair of "?:" operators. 1 Link to comment Share on other sites More sharing options...
niche Posted August 16, 2012 Author Share Posted August 16, 2012 I know the simple ternary reads if-then-else. How does the one in the op read? Link to comment Share on other sites More sharing options...
ShadowMage Posted August 16, 2012 Share Posted August 16, 2012 (edited) Ternary operators can be nested just like if/else statements. When expanded, the ternary in the OP might look something like this: var val; // Start of the ternary syntax conversionif (window.Event) { //Condition from first ternary //"True" portion of first ternary val = e.pageY;} else { //"False" or "else" portion of first ternary val = event.clientY; if (document.documentElement.scrollTop) { //Condition from second ternary //"True" portion of second ternary val += document.documentElement.scrollTop; } else { //"False" or "else" portion of second ternary val += document.body.scrollTop; }}//End of the ternary syntax conversion document.getElementById('cursorY').value = val; Edited August 16, 2012 by ShadowMage 1 Link to comment Share on other sites More sharing options...
niche Posted August 16, 2012 Author Share Posted August 16, 2012 (edited) Outstanding topic ShadowMage & justsomeguy. Thanks for all the extra attention to detail ShadowMage. It's appreciated very much. Niche Edited August 16, 2012 by niche Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now