Adding Number Strings Without Using Parse Int() in java script.
We all know that java script contains many features and one of the best feature of java script is Parse Int().
Using Parse Int() we can convert string to a number. For Example let us consider
“1” +1; what should be the output of this, its concatenate and gives you result 11.
But using Parse Int(“1”) +1 the output will be 2 as i mention Parse int() converts the string into a number.
But any alternate method to do this without using Parse Int() method the answer is yes.
Here Negative operator can do this task very easily without using Parse Int() because Negative operator have tendency to first convert the string into integer. For Example:
“1”- 1 = 0;
“1” - ”1" = 0;
So if we want to add string without using Parse Int() it can be done by using two Negative operators;
“1” - (- 1) = 2;
“1” - (- ”1") = 2;