or operator in javascript
//The OR operator in Javascript is 2 verticals lines: ||
var a = true;
var b = false;
if(a || b) {
//one of them is true, code inside this block will be executed
}
or operator in javascript
//The OR operator in Javascript is 2 verticals lines: ||
var a = true;
var b = false;
if(a || b) {
//one of them is true, code inside this block will be executed
}
less than or equal to javascript
if(a <= 5){
yourFunction();
}
js logical operators
Javascript Logical Operators
&& Logical and
|| Logical or
! Logical not
and operator in javascript
//&& 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
How does logical operators && works in javascript?
const num = 6;
if (num <= 7 && num <= 8) {
console.log('true')
} else {
console.log('false')
}
//Expected output:true
logical operators in 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)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us