//Revision Lecture 12: 8 Oct 2022
//Topic 8: //* operators *// logical operators, ternary operator, typeof operator //
//C) logical operators
// &&, ||, !
//1) && (and)
console.log(true && true)
// output--> true
console.log(true && false)
// output--> false
console.log(false && true)
// output--> false
console.log(false && false)
// output--> false
console.log('-------------')
//examples:
// true true
console.log(1 > 0 && 2 > 1)
//output--> true
// true false
console.log(3 < 4 && 5 < 3)
//output--> false
// false true
console.log(6 > 7 && 8 > 5)
//output--> false
// false false
console.log(8 < 5 && 6 > 8)
//output--> false
console.log('-------------')
//2) || (or)
console.log(true || true)
//output--> true
console.log(true || false)
//output--> true
console.log(false || true)
//output--> true
console.log(false || false)
//output--> false
console.log('-------------')
//examples:
// true true
console.log(11 > 10 || 10 > 9)
//output-> true
// true false
console.log(12 > 9 || 9 > 12)
//output-> true
// false true
console.log(15 > 16 || 16 > 15)
//output-> true
// false false
console.log(17 < 16 || 16 < 15)
//output-> false
console.log('-------------')
//3) ! (not)
//!true
//output--> false
//!false
// output--> true
//examples:
console.log(!true)
//output-> false
console.log(!false)
//output-> true
// false
console.log(5 != 5)
//output-> false
// true
console.log(5 != 6)
//output-> true
console.log('-------------')
//D) ternary operator ?
5>4? console.log("Hello"):console.log("bye")
6<4? console.log("Hello"):console.log("bye")
15 === 15? console.log("Hello"):console.log("bye")
15 === '15'? console.log("Hello"):console.log("bye")
//E) typeof operator: shows the data type
console.log(typeof 2)
console.log(typeof 'ram')
console.log(typeof {})
टिप्पण्या
टिप्पणी पोस्ट करा
आपल्या प्रतिक्रियेबद्दल धन्यवाद ! आम्ही लवकरात लवकर प्रतिक्रियेला उत्तर देण्याचा प्रयत्न करू