JavaScript enforcement, order priority and associativity can be confusing, but I use the link below to figure this out.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
But I still donβt understand why "1"+"1"as a result "11"and "1"- - "1"as a result 2,
"1"+"1"
"11"
"1"- - "1"
2
- -should be converted to +, and it should be handled as "1"+"1". What am I missing here?
- -
+
You can check it out here:
console.log("1" + "1"); console.log("1"- - "1");
- - -. , "1"- - "1" "1" - (-"1"), "1" - (-1), - , 1 - (-1), 2.
-
"1" - (-"1")
"1" - (-1)
1 - (-1)
"1"+"1" . + , string, -.
string
"1" - - "1" javascript - , . , NaN. , "1" - - "1" "1" - (- "1"). , , -, "1" ( ) (-"1") .
"1" - - "1"
"1" - (- "1")
"1"
(-"1")
:
"foo" + 1 foo1, +
"foo" + 1
foo1
: "foo" - 1 NaN, . / *.
"foo" - 1
NaN
/
*
Source: https://habr.com/ru/post/1690865/More articles:Why can't I delete a row attached to it using Doctrine 2 - mysqlAutomapper does not correctly display a null List element when a condition is specified! = Null - c #C ++ beginner: Why doesn't the compiler find my functions in the header? - c ++SonarQube process terminated with exit value [es]: 137 - debianWhat does "S" mean in hexadecimal number? - vb.netWhy is there 1 == '1 \ n' true in JavaScript? - javascriptHow to use PresentationCore in WebAPI hosted on Azure? - wpfHow to find input string with mixed types - pythonCoordinator mark is dead - apache-kafkaWhy can't I return the ByteString from the handler to Yesod? - haskellAll Articles