JavaScript assignment operator is equal (=) which assigns the value of the right-hand operand to its left-hand operand. That is if a = b assigns the value of b to a.
The simple assignment operator is used to assign a value to a variable. The assignment operation evaluates the assigned value. Chaining the assignment operator is possible in order to assign a single value to multiple variables.
Syntax
data=value
<!DOCTYPE>
<html>
<head>
<title>JavaScript</title>
<script>
/* Equalto Assignment Operators */
var m = 10;
var n = 3;
o = m + n;
document.write(o);
document.write('<br><br>');
/* Addition Assignment Operators */
var a = 10;
var b = 3;
a += b;
document.write(a);
document.write('<br><br>');
/* Subtraction Assignment Operators */
var m = 10;
var n = 3;
m -= n;
document.write(m);
document.write('<br><br>');
/* Multiplication Assignment Operators */
var p = 10;
var q = 3;
p *= q;
document.write(p);
document.write('<br><br>');
/* Exponentiation Assignment Operators */
var d = 10;
var e = 3;
d **= e;
document.write(d);
document.write('<br><br>');
/* Division Assignment Operators */
var s = 10;
var t = 3;
s /= t;
document.write(s);
document.write('<br><br>');
/* Modulus(Remainder) Assignment Operators */
var x = 10;
var y = 3;
x %= y;
document.write(x);
document.write('<br><br>');
</script>
</head>
<body>
</body>
</html>
No comments:
Post a Comment