“Operadores lógicos JavaScript” Respostas de código

Operadores lógicos JavaScript

Operator	Description	Example
&&	Logical AND: true if both the operands are true, else returns false	x && y
||	Logical OR: true if either of the operands is true; returns false if both are false	x || y
!	Logical NOT: true if the operand is false and vice-versa.	!x
SAMER SAEID

=== JavaScript

// ===	means equal value and equal type
var x = 5

// true
x === 5

// false
x === "5"
Lazy Lapwing

Operadores lógicos em JavaScript

// logical AND
console.log(true && true); // true
console.log(true && false); // false

// logical OR
console.log(true || false); // true

// logical NOT
console.log(!true); // false
SAMER SAEID

Operadores lógicos em JavaScript

n1 = !true               // !t returns false (the opposite of true)
n2 = !false              // !f returns true (the opposite of false)
n3 = !''                 // !f returns true (in JavaScript, an empty string is falsey, thus the opposite of a falsey value here is truthy.)
n4 = !'Cat'              // !t returns false (non empty string is truthy, thus opposite is falsy)
deejay

Comparação de JavaScript e operadores lógicos

if (age < 18) text = "Too young to buy alcohol";
naly moslih

Respostas semelhantes a “Operadores lógicos JavaScript”

Procure respostas de código populares por idioma

Procurar outros idiomas de código