js logical operators
//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
}Javascript Comparison Operators
== Equal to
=== Equal value and equal type
!= Not equal
!== Not equal value or not equal type
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
? Ternary operator
Javascript Logical Operators
&& Logical and
|| Logical or
! Logical not
var hungry=true;
var slow=true;
var anxious=true;
//&& means and
if(hungry && slow && anxious){
var cause="weed";
}var x = 5;
// === equal value and equal type
// e.g. 1.
x === 5 returns true
// e.g. 2.
x === "5" returns false
// !== not equal value or not equal type
// e.g. 1.
x !== 5 returns false
// e.g. 2.
x !== "5" returns true
// e.g. 3.
x !== 8 returns truelet a = 1;
let b = -1;
if (a > 0 & b > 0){
console.log("and");
} else if (a > 0 || b > 0){
console.log("or");
}
Also in JavaScript:
- how to copy one array to another in javascript
- get element by id two ids
- javascript string concat vs +
- ajax
- verify input is not Nan js
- get number right of the dot length javascript
- TypeError: Object of type ndarray is not JSON serializable
- node-fetch auth basic
- node js with express medium
- es6 method definition syntax
- js this returns undefined
- react fontawesome
- for key value in object javascript
- javascript combine two index elements
- add new items in a select input using js
- split in js
- conflict paypal api javascript with user agent Mozilla/5.0 Google
- array destructuring in javascript
- iframe reload parent page
- javascript fs read
- json object check if key exists java
- factorial javascript function
- jquery use variable in string "without" concatenate
- arrow function javascript