-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path03-JS-precedence-operators.js
More file actions
150 lines (141 loc) · 6.63 KB
/
03-JS-precedence-operators.js
File metadata and controls
150 lines (141 loc) · 6.63 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
=====================
JavaScript Precedence Operators
=====================
*/
/*
===========================================
>> 01- JavaScript Arithmetic Operators
===========================================
*/
console.log("01- JavaScript Arithmetic Operators");
var x = 100 + 50;
console.log("x = " + x);
// Modulus
var x = 5;
var y = 2;
var z = x % y;
console.log("z = x % y = " + z);
// Incrementing
var x = 5;
x++;
var z = x;
console.log("z = " + z);
/*
See More:
==========
Operator| Description
-------------------------------
| + | Addition
-------------------------------
| - | Subtraction
-------------------------------
| * | Multiplication
-------------------------------
| / | Division
-------------------------------
| % | Modulus
-------------------------------
| ++ | Increment
-------------------------------
| -- | Decrement
-------------------------------
*/
/*
===========================================
>> 01- JavaScript Precedence Operators
===========================================
*/
console.log("02- JavaScript Precedence Operators");
var x = 100 + 50 * 3;
console.log("x = " + x);
var x = (100 + 50) * 3;
console.log("x = " + x);
/*
See More:
==========
| Operator | Description | Example
------------------------------------------------------------------
| ( ) | Expression grouping | (3 + 4)
------------------------------------------------------------------
| . | Member | person.name
------------------------------------------------------------------
| [] | Member | person["name"]
------------------------------------------------------------------
| () | Function call | myFunction()
------------------------------------------------------------------
| new | Create | new Date()
------------------------------------------------------------------
| ++ | Postfix Increment | i++
------------------------------------------------------------------
| -- | Postfix Decrement | i--
------------------------------------------------------------------
| ++ | Prefix Increment | ++i
------------------------------------------------------------------
| -- | Prefix Decrement | --i
------------------------------------------------------------------
| ! | Logical not | !(x==y)
------------------------------------------------------------------
| typeof | Type | typeof x
------------------------------------------------------------------
| * | Multiplication | 10 * 5
------------------------------------------------------------------
| / | Division | 10 / 5
------------------------------------------------------------------
| % | Modulo division | 10 % 5
------------------------------------------------------------------
| ** | Exponentiation | 10 ** 2
------------------------------------------------------------------
| + | Addition | 10 + 5
------------------------------------------------------------------
| - | Subtraction | 10 - 5
------------------------------------------------------------------
| << | Shift left | x << 2
------------------------------------------------------------------
| >> | Shift right | x >> 2
------------------------------------------------------------------
| >>> | Shift right (unsigned) | x >>> 2
------------------------------------------------------------------
| < | Less than | x < y
------------------------------------------------------------------
| <= | Less than or equal | x <= y
------------------------------------------------------------------
| > | Greater than | x > y
------------------------------------------------------------------
| >= | Greater than or equal | x >= y
------------------------------------------------------------------
| == | Equal | x == y
------------------------------------------------------------------
| === | Strict equal | x === y
------------------------------------------------------------------
| != | Unequal | x != y
------------------------------------------------------------------
| !== | Strict unequal | x !== y
------------------------------------------------------------------
| && | Logical and | x && y
------------------------------------------------------------------
| || | Logical or | x || y
------------------------------------------------------------------
| = | Assignment | x = y
------------------------------------------------------------------
| += | Assignment | x += y
------------------------------------------------------------------
| -= | Assignment | x -= y
------------------------------------------------------------------
| *= | Assignment | x *= y
------------------------------------------------------------------
| %= | Assignment | x %= y
------------------------------------------------------------------
| <<= | Assignment | x <<= y
------------------------------------------------------------------
| >>= | Assignment | x >>= y
------------------------------------------------------------------
| >>>= | Assignment | x >>>= y
------------------------------------------------------------------
| &= | Assignment | x &= y
------------------------------------------------------------------
| ^= | Assignment | x ^= y
------------------------------------------------------------------
| |= | Assignment | x |= y
------------------------------------------------------------------
*/