Ad

JavaScript Logical Operator

 


  Logical Operator

  1]  logical and (&&)

  2] logical or ( | | )

  3]  logical ( ! )

Logical Operator 

Example :-

Logical Operator

 Logical Operator

  1]  logical and (&&)

Example :-

//True and False value = False
 let s =true;
 let t=false;
  let result= s && t;
  console.log(result);

  // True and True value = True
  let u = true;
  let v= true;
  let result1= u&&v;
  console.log(result1);
  //False and True value = False
  let w=false;
  let x=true;
  let result2= w && x;
  console.log(result2);

  //False and False value = False
  let y=false;
  let z=false;
  let result3=y &&z;
  console.log(result3);

Output:-

logical and (&&)


  2] logical or ( | | ) 

Example :-

//True and False value = True
 let s =true;
 let t=false;
  let result= s || t;
  console.log(result);

  // True and True value = True
  let u = true;
  let v= true;
  let result1= u||v;
  console.log(result1);
  //False and True value = True
  let w=false;
  let x=true;
  let result2= w || x;
  console.log(result2);

  //False and False value = False
  let y=false;
  let z=false;
  let result3=y ||z;
  console.log(result3);

Output:-

logical or ( | | )


  3]  logical ( ! )

Example :-


// value not true = false
let q=true;
let result =!q;
console.log(result);
// value not false = true
 let a= false;
 let result2=!a;
 console.log(result2);

Output:-



Related Post:-

php program to print alphabet pattern G

php program check to even or odd number

css element selector

No comments

Powered by Blogger.