0
Q:

javascript &&

// " && " in Javascript is the operator for AND. 
1
// || means or
4
let a = true;

let b = !a;

console.log(b); //output: false
1
//&& returns true if both values are true
//or returns the second argument if the first is true
var a = true
var b = ""
var c = 1

true && "" //""
"" && 1 //""
false && 5 //false
2
false && expr; //Não preciso avaliar expr, pois o resultado é sempre falsetrue || expr;//Não preciso avaliar expr, pois o resultado é sempre false
0
//& (bitwise AND) operator
console.log(5 & 13); //outout: 5
/*
5  = 0101 (base 2)
13 = 1101 (base 2)
//AND every bit together from both numbers
+----+
|0101|
|1101|
+----+
|0101|
+----+
0101 = 5 (base 10)
*/
0
a1 = true  && true       // t && t returns true
a2 = true  && false      // t && f returns false
a3 = false && true       // f && t returns false
a4 = false && (3 == 4)   // f && f returns false
a5 = 'Cat' && 'Dog'      // t && t returns "Dog"
a6 = false && 'Cat'      // f && t returns false
a7 = 'Cat' && false      // t && f returns false
a8 = ''    && false      // f && f returns ""
a9 = false && ''         // f && f returns false
1

New to Communities?

Join the community