Guest User

Untitled

a guest
Jun 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. console.log(1 + 2);
  2. console.log(1 + "s");
  3.  
  4. // Number + Number -> addition
  5. 1 + 2 // 3
  6.  
  7. // Boolean + Number -> addition
  8. true + 1 // 2
  9.  
  10. // Boolean + Boolean -> addition
  11. false + false // 0
  12.  
  13. // Number + String -> concatenation
  14. 5 + 'foo' // "5foo"
  15.  
  16. // String + Boolean -> concatenation
  17. 'foo' + false // "foofalse"
  18.  
  19. // String + String -> concatenation
  20. 'foo' + 'bar' // "foobar"
  21.  
  22. operand + operand = result
  23.  
  24. var result = 'b' + 'a' + + 'a' + 'a';
  25.  
  26. >> baNaNa
  27.  
  28. var result = [1, 2, 3] + [4, 5, 6];
  29. console.log(result);
  30.  
  31. >> '1,2,34,5,6'
Add Comment
Please, Sign In to add comment