Skip to content

Instantly share code, notes, and snippets.

@chuckha
Created February 18, 2012 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuckha/1856747 to your computer and use it in GitHub Desktop.
Save chuckha/1856747 to your computer and use it in GitHub Desktop.
javascript string and integer addition/concatenation
// The first three are strings, the last is a number
"1" + "2" = "12";
"1" + 2 = "12";
1 + "2" = "12";
1 + 2 = 3;
// These are all numbers
"1" - 2 = -1;
"1" - "2" = -1;
1 - "2" = -1;
1 - 2 = -1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment