R: += (plus equals) and ++ (plus plus) equivalent from c++/c#/java, etc.?
No, it doesn't, see: R Language Definition: Operators
What is += in Javascript?
It is the addition assignment
operator (+=
) to add a value to a variable.
Depending of the current type of the defined value on a variable, it will read the current value add/concat another value into it and define on the same variable.
For a string
, you concat the current value with another value
let name = "User";
name += "Name"; // name = "UserName";
name += " is ok"; // name = "UserName is ok";
It is the same:
var name = "User";
name = name + "Name"; // name = "UserName";
name = name + " is ok"; // name = "UserName is ok";
For numbers, it will sum the value:
let n = 3;
n += 2; // n = 5
n += 3; // n = 8
In Javascript, we also have the following expressions:
-=
- Subtraction assignment;/=
- Division assignment;*=
- Multiplication assignment;%=
- Modulus (Division Remainder) assignment.
Java plus equals or equals plus operator?
It's not the same.
x+=5
is equivalent to x=x+5
.
x=+5
(or x=(+5)
) is equivalent to x=5
.
Plus equals operator error
use parseInt()
function to each amount which is getting from prompt
amount = parseInt(prompt("Enter the amount you want to deposit: $"), 10);
DEMO
Related Topics
How to Set Multiple CSS Styles in JavaScript
Why Does This JavaScript Code Print "Undefined" on the Console
How to Get Selected HTML Text with JavaScript
How to Do Associative Array/Hashing in JavaScript
Adding Console.Log to Every Function Automatically
How to Access Local Scope Dynamically in JavaScript
Adding Custom Properties to a Function
Manipulating Innerhtml Removes the Event Handler of a Child Element
Calling a JavaScript Function Named in a Variable
What's the Difference Between Window.Location= and Window.Location.Replace()
Sort Mixed Alpha/Numeric Array
Get the Index of the Object Inside an Array, Matching a Condition
How to Profile JavaScript Execution
Benefits of Prototypal Inheritance Over Classical
Selected Text Event Trigger in JavaScript