“Operator logis JavaScript” Kode Jawaban

Operator logis 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

Operator logis di 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

operator logis di 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

Perbandingan JavaScript dan operator logis

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

Jawaban yang mirip dengan “Operator logis JavaScript”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya