-
Notifications
You must be signed in to change notification settings - Fork 0
/
operators.js
73 lines (40 loc) · 1.51 KB
/
operators.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// assignment operator used to assign value to variables
let d = "string"
d += 1 //increment assignment operator
d -= 1 //decrement assignment
d *= 2 //multiplication assignment
d /= 3 // division assignment
d **= 2 //exponential assignment
// Arithmetic operator is consists of
// arithmetic operations on numbers
console.log("Addition ",5 + 7)
console.log("Subtraction ",6 - 3)
console.log("Multiplication ",7 * 1)
console.log("Division ",9 / 3)
console.log("Modulus ",9 % 2)
console.log("Exponential ",7**2)
// Comparison operator used to compare values
// and returns boolean values
console.log(6 == 4) //equals or not
console.log(7 > 9) //greater than
console.log(7 <= 9) // less than/equal to, and so on
// Logical operator used to write logical functions
// also returns boolean value
8 && 8 // logical and, returns true if both true else false
8 || 7 // logical or, returns true if one of two is true
!true // logical not, returns opposite value
// increment/decrement operator is used on variables to
// increase/decrease thier value as postly or previously
let a = 6
console.log("default value ", a)
console.log("post increment/decrement shows changes on same line", a++)
console.log('after increase in previous line',a)
console.log("pre decrement/increment shows changes on same line", --a)
console.log("after decrease in previous line", a)
// Bitwise operators are used to do bitwise functions
// like: &, |, ~, ^, <<, >>, >>>
// single line comment
/* multi
line
comment
*/