JS - Day 3

// Logical operations

//1) And &&

// true && true      // meaning - both statements true // result: true
// false && true     // meaning - 1st statement false & 2nd true // result: false
// true && false     // meaning - 1st statement true & 2nd false // result: false
// false && false    // meaning - both statements false // result: false

//2) Or ||

// true || true      // meaning - both statements true // result: true   
// false || true     // meaning - 1st statement false OR 2nd true // result: true
// true || false     // meaning - 1st statement true OR 2nd false // result: true
// false || false    // meaning - both statements false // result: false

//3) Not !

// ! true       // meaning - statement not true // result: false
// ! false      // meaning - statement not false // result: true

// Examples of && (AND)

console.log(6==6 && 6!=='6')    // here 1st statement is true & 2nd statement also true // result: true
console.log(6=='6' && 6<5)      // here 1st statement is true & 2nd is false // result: false
console.log(6>7 && 6==6)        // here 1st statement is false & 2nd is true // result: false
console.log(6==8 && 5!==5)      // here 1st statement is false & 2nd is also false // result: false

// Examples of || (OR)

console.log(6==6 || 6!=='6')    // here 1st statement is true & 2nd statement also ture // result: true
console.log(6=='6' || 6<5)      // here 1st statement is true & 2nd is false // result: true
console.log(6>7 || 6==6)        // here 1st statement is false & 2nd is true // result: true
console.log(6==8 || 5!==5)      // here 1st statement is false & 2nd is also false // result: false

// Examples of ! (NOT)

console.log(!(6==6))    // meaning - true statement is not true // result: false
console.log(!(8!==8))   // meaning - false statement is not false // result: true



-blog by Ashish Naik

Comments

Popular posts from this blog

What is IP and TCP - Marathi

JS - Day 1

JS - basic types and ways of writing function