String concatenation is done with +
so Javascript will convert the first numeric 1 to a string and concatenate “1” and “1” making “11”.
You cannot perform subtraction on strings, so Javascript converts the second “1” to a number and subtracts 1 from 1, resulting in zero.
More Related Contents:
- JavaScript adding a string to a number
- Evaluating a string as a mathematical expression in JavaScript
- How can I extract a number from a string in JavaScript?
- What’s the best way to convert a number to a string in JavaScript?
- Javascript Thousand Separator / string format [duplicate]
- Check whether an input string contains a number in javascript
- JavaScript string and number conversion
- How to convert a String containing Scientific Notation to correct Javascript number format
- How can val() return Number?
- Why does a shift by 0 truncate the decimal?
- Javascript: How to retrieve the number of decimals of a *string* number?
- Logical operator && and two strings in javascript
- JavaScript plus sign in front of function expression
- Fastest method to escape HTML tags as HTML entities?
- Split large string in n-size chunks in JavaScript
- Check if a variable is a string in JavaScript
- Optimum way to compare strings in JavaScript? [duplicate]
- How to create streams from string in Node.Js?
- What does ${} (dollar sign and curly braces) mean in a string in JavaScript?
- JavaScript replace() method dollar signs
- How can I use jQuery to style /parts/ of all instances of a specific word?
- Is there a JavaScript strcmp()?
- HTML input type=”number” still returning a string when accessed from javascript
- What’s the point of new String(“x”) in JavaScript?
- What does “somevar >> 0” mean?
- How to remove part of a string?
- Javascript unicode string, chinese character but no punctuation
- Extract the text out of HTML string using JavaScript
- Print / display a JavaScript variable’s name instead of it’s value
- How to count the number of lines of a string in javascript