@@ -125,54 +125,63 @@ console.log(typeof num2); //string
125
125
let num3 = 5 ;
126
126
console . log ( typeof num3 ) ; //number
127
127
128
- console . log ( num2 == num3 ) ; //true Loose Equality just check the value
129
- console . log ( num2 === num3 ) ; //false Strict Equality check the value and type of data both
128
+ console . log ( num2 == num3 ) ; //true because Loose Equality just check the value
130
129
131
- // Ternary Operator:
130
+ console . log ( num2 === num3 ) ; //false because Strict Equality check the value and type of data both
132
131
133
- //Syntax: condition ? expression1 : expression2
132
+ /* Ternary Operator:
133
+
134
+ Syntax: condition ? expression1 : expression2
134
135
135
136
let age = 20;
136
137
let check = age > 18 ? 'I can vote' : 'I cannot vote';
137
- console . log ( check ) ; //I can vote
138
+ console.log(check);
138
139
140
+ Output: I can vote
141
+ */
139
142
//__________________________________________________________________________________________
140
143
141
- //4. Logical Operators: [&&, ||, !]:
144
+ /* 4. Logical Operators: [&&, ||, !]:
145
+
146
+ 1. Logical AND (&&):
147
+
148
+ => It returns true if all the conditions are true.
149
+ => If any one of the conditions is false, it returns false.
150
+ => It is denoted by '&&'
151
+ => Syntax: condition1 && condition2
152
+
153
+ 2. Logical OR (||):
142
154
143
- //1. Logical AND (&&): It returns true if all the conditions are true.
144
- // If any one of the conditions is false, it returns false.
145
- // It is denoted by '&& '
146
- // Syntax: condition1 && condition2
155
+ => It returns true if any one of the conditions is true.
156
+ => If all the conditions are false, it returns false.
157
+ => It is denoted by '|| '
158
+ => Syntax: condition1 || condition2
147
159
148
- //2. Logical OR (||): It returns true if any one of the conditions is true.
149
- //If all the conditions are false, it returns false.
150
- //It is denoted by '||'
151
- //Syntax: condition1 || condition2
160
+ 3. Logical NOT (!):
152
161
153
- //3. Logical NOT (!): It returns the opposite of the condition.
154
- // If the condition is true, it returns false.
155
- // If the condition is false, it returns true.
156
- // It is denoted by '!'
157
- // Syntax: !condition
162
+ => It returns the opposite of the condition.
163
+ => If the condition is true, it returns false.
164
+ => If the condition is false, it returns true.
165
+ => It is denoted by '!'
166
+ => Syntax: !condition */
158
167
159
168
let ans = ( true && true && true ) ;
160
- console . log ( ans ) ; // true
169
+ console . log ( ans ) ; //It will return ' true' because all the conditions are true.
161
170
162
171
let ans1 = ( true && true && false ) ;
163
- console . log ( ans1 ) ; // false
172
+ console . log ( ans1 ) ; //It will return ' false' because one of the conditions is false.
164
173
165
174
let ans2 = ( true || false || false ) ;
166
- console . log ( ans2 ) ; // true
175
+ console . log ( ans2 ) ; //It will return ' true' because one of the conditions is true.
167
176
168
177
let ans3 = ( false || false || false ) ;
169
- console . log ( ans3 ) ; // false
178
+ console . log ( ans3 ) ; //It will return ' false' because all the conditions are false.
170
179
171
180
let ans4 = ! ( true ) ;
172
- console . log ( ans4 ) ; //false
181
+ console . log ( ans4 ) ; //false
173
182
174
183
let ans5 = ! ( false ) ;
175
- console . log ( ans5 ) ; //true
184
+ console . log ( ans5 ) ; //true
176
185
177
186
//AND Operator:
178
187
@@ -232,7 +241,7 @@ console.log(!isFirst); //false //It will return false because the value of isFi
232
241
//Truthy values: A value is considered truthy if it is not false.
233
242
//Falsy values: A value is considered falsy if it is false, [null, undefined, 0, NaN, or an empty string].
234
243
235
- console . log ( false || 'Balaram' ) ; //Balaram
236
- console . log ( false || 7 ) ; //7
244
+ console . log ( false || 'Balaram' ) ; //Balaram
245
+ console . log ( false || 7 ) ; //7
237
246
console . log ( false || 7 || 8 || 9 ) ; //7 //It will return the first truthy value it encounters
238
247
0 commit comments