Reputation: 2610
Going through an online test, i found this weird expression where
"1"- -"1" = 2
i understand -"1"
will be converted to number, but the other "1"-
is getting converted too?
Upvotes: 2
Views: 89
Reputation: 44087
You can't subtract strings - so they are converted to numbers:
1 - -1
Two minuses make a plus:
1 + 1
And if you can prove it, that is equal to 2:
1 + 1 = 2
console.log("1" - - "1");
Upvotes: 6