0
Javascript
What is the difference between "sum += (variable)" and "sum =+ (variable)"?
7 ответов
0
Here is an example:
https://code.sololearn.com/WCYNfxqRJeBV/?ref=app
+ 2
Yes. You are correct, but this was not the case.
+ 1
First is equivalent with sum = sum + (variable). This means that the value of sum is increased by the value of (variable)
Second is equivalent with sum = (variable). This means that the value of sum becomes the value of (variable)
0
Gabriel Ilie, Hi! why do you put the "nr" variable in brackets in your code example?
0
No reason. Just to note that the brackets have no impact in the result
0
in some cases, parentheses have a value. in them, the expression is evaluated first
0
maybe in this question the second part of the example refers to the use of the unary plus? that is, if a negative value is stored in a variable, then plus converts it to a positive value