Skip to content

Instantly share code, notes, and snippets.

@rajat2502
Last active May 15, 2021 13:06
Show Gist options
  • Save rajat2502/d4fa0484df776d0d5272a6ceef7d9c83 to your computer and use it in GitHub Desktop.
Save rajat2502/d4fa0484df776d0d5272a6ceef7d9c83 to your computer and use it in GitHub Desktop.
var x = 10;
var y = "10";
// Case 1: when the variables are added
console.log(x + y);
// Output: 1010
// Case 2: when the variables are subtracted
console.log(x - y);
// Output: 0
/* When a number and string are to be added then the number is converted into a string but
when they are to be subtracted the string is converted into a number. */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment