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

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 11  |  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. How is the ternary operator evaluated in JavaScript?
  2. (1)? functionOne(): functionTwo()
  3.        
  4. function functionOne(){
  5.    alert("one");
  6. }
  7. function functionTwo(){
  8.    alert("two");
  9. }
  10.        
  11. function bool() {
  12.     alert('bool');
  13.     return false;
  14. }
  15.  
  16. function a() {
  17.     alert('a');
  18.     return 'A';
  19. }
  20.  
  21. function b() {
  22.     alert('b');
  23.     return 'B';
  24. }
  25.  
  26. alert(bool() ? a() : b())