1<!--Add two integer numbers using JavaScript.-->
2<html>
3 <head>
4 <title>Add two integer numbers using JavaScript.</title>
5 <script type="text/javascript">
6 function addTwoNumbers(textBox1, textBox2){
7 var x=document.getElementById(textBox1).value;
8 var y=document.getElementById(textBox2).value;
9 var sum=0;
10 sum=Number(x)+Number(y);
11 alert("SUM is: " + sum);
12 }
13 </script>
14 </head>
15<body>
16 <h1>Add two integer numbers using JavaScript.</h1>
17 <b>Enter first Number: </b><br>
18 <input type="text" id="textIn1"/><br>
19 <b>Enter second Number: </b><br>
20 <input type="text" id="textIn2"/><br><br>
21 <input type="button" id="btnSum" value="Calculate SUM" onClick="addTwoNumbers('textIn1','textIn2')"/>
22</body>
23
24</html>
25
1== equal to
2=== equal value and equal type
3!= not equal
4!== not equal value or not equal type
5> greater than
6< less than
7>= greater than or equal to
8<= less than or equal to
9? ternary operator
1= assignment operator
2var x = 2
3
4
5+ addition operator
62 + 3 = 5
7
8
9- subtraction operator
102 - 3 = -1
11
12
13* multiplicative operator
142 * 3 = 6
15
16
17/ division operator
183 / 2 = 1.5
19
20
21% modulus operator
223 % 2 = 1
23
24
25++ increment operator
26var x = 2
27x++
28// x now equals 3 (x = x + 1 in literal notation)
29
30
31-- decrement operator
32var x = 3
33x--
34// x now equals 2 (x = x - 1 in literal notation)
35
36
37+= additive reassignment operator
38var x = 2
39x += 3
40// x now equals 5 (x = x + 3 in literal notation)
41
42
43-= subtractive reassignment operator
44var x = 3
45x -= 2
46// x now equals 1 (x = x - 2 in literal notation)
47
48
49*= multiplicative reassignment operator
50var x = 3
51x *= 2
52// x now equals 6 (x = x * 2 in literal notation)
53
54
55/= division reassignment operator
56x = 3
57x /= 2
58// x now equals 1.5 (x = x / 2 in literal notation)
59
60
61%= modulus reassignment operator
62x = 3
63x %= 2
64// x now equals 1 (x = x % 2 in literal notation)
65
66
67== logical comparison operator
682 == 2 // Returns true
692 == "2" // Returns true
702 == 3 // Returns false
71
72
73=== logical strict comparison operator
742 === 2 // Returns true
752 === "2" // Returns false
762 === 3 // Returns false
77
78
79!= logical not equal comparison operator
802 != 3 // Returns true
812 != 2 // Returns false
822 != "2" // Returns false
83
84
85!== logical not equal strict comparison operator
862 !== 3 // Returns true
872 !== 2 // Returns false
882 !== "2" // Returns true
89
90
91< logical less than comparison operator
922 < 3 // Returns true
933 < 2 // Returns false
94
95
96> logical greater than comparison operator
973 > 2 // Returns true
982 > 3 // Returns false
993 > 3 // Returns false
100
101
102<= logical less than or equal to comparison operator
1032 <= 3 // Returns true
1043 <= 3 // Returns true
1053 <= 2 // Returns false
106
107
108>= logical less than or equal to comparison operator
1093 >= 2 // Returns true
1103 >= 3 // Returns true
1112 >= 3 // Returns false
112
113
114|| logical or operator
115x = 3
116(x == 3 || x == 2) // Returns true
117(x == 2 || x == 1) // Returns false
118
119
120&& logical and operator
121x = 2
122y = 3
123(x == 2 && y == 3) // Returns true
124(x == 2 && y == 4) // Returns false
1// Javascript Airthmetic Operators
2+ : Addition
3- : Subtraction
4* : Multiplication
5** : Exponentiation (ES2016)
6/ : Division
7% : Modulus (Division Remainder)
8++ : Increment
9-- : Decrement
1/* JavaScript shorthand -=
2-= is shorthand to subtract something from a
3variable and store the result as that same variable.
4*/
5
6// The standard syntax:
7var myVar = 5;
8console.log(myVar) // 5
9var myVar = myVar - 3;
10console.log(myVar) // 2
11
12// The shorthand:
13var myVar = 5;
14console.log(myVar) // 5
15var myVar -= 3;
16console.log(myVar) // 2
17