Assignment Operators tutorial in JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Assignment Operators JavaScript</title>
<script>
// Assignment operators are shorthand of Arithmetic operators
var a = 10;
var b = 3;
a += b; //same as a = a + b;
document.write(a);
a -= b; //same as a = a - b;
document.write("<br>");
document.write(a);
document.write("<br>");
a *= b; //same as a = a * b;
document.write(a);
document.write("<br>");
a /= b; //same as a = a / b;
document.write(a);
document.write("<br>");
// a %= b; //same as a = a % b;
// document.write(a);
document.write("<br>");
a **= b; //same as a = a ** b;
document.write(a);
</script>
</head>
<body>
<h1>Assignment Operators JavaScript</h1>
</body>
</html>
.png)
.png)
Comments
Post a Comment