Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. What does the end part of this declaration do?
  2. result = condition ? value_if_true : value_if_false;
  3.        
  4. if(condition == true) {
  5.  
  6.     result = value_if_true;
  7.  
  8. } else {
  9.  
  10.     result = value_if_false;
  11.  
  12. }
  13.        
  14. result = myVariable ? value if true : value if false;
  15.  
  16. result = myFunction() ? value if true : value if false;
  17.  
  18. result = (myVariable > 10) ? value if true : value if false;
  19.        
  20. condition_check ? result if true : result if false
  21.        
  22. var u;
  23. if(document.getElementById('myaccount').className.match(/loggedin/)) {
  24.     u = true;
  25. } else {
  26.     u = false;
  27. }
  28. return u;
  29.        
  30. <condition> ? <return if condition is true> : <return if condition is false>
  31.        
  32. var u;
  33. if (document.getElementById('myaccount').className.match(/loggedin/)){
  34.    u = 'true';
  35. } else {
  36.    u = 'false';
  37. }