Toán tử trong javascript - Version đầy đủ

javascript,operator

javascript and operator

//AND Operator expressed as &&

const x = 7;
const y = 4;

(x == 7 && y == 5); // false
(x == 3 && y == 4); // false
(x == 7 && y == 4); // true

if (condition == value && condition == otherValue) {
  return something;
}

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
}

javascript and

var hungry=true;
var slow=true;
var anxious=true;

//&& means and
if(hungry && slow && anxious){ 
    var cause="weed";
}

or statment javscript

if (x === 5 || x === 8)
  console.log("x is eaqual to 5 OR 8")

or operator javascript

var a = 2;
var b = 5;
var c = 10;

if (a === 3 || a === 2) {
    console.log("TRUE");
} else {console.log("FALSE");}
if (a === 4 || b === 3 || c === 11) {
    console.log("TRUE");
} else {console.log("FALSE");}
if (b === 5 || c != 10) {
    console.log("TRUE");
} else {console.log("FALSE");}

/* Output:
TRUE
FALSE
TRUE
*/

eaqual signs in javascript

//x = 5

operator  |    example     |    output  |    explination

==            x == 8        false        equal to
            x == 5        true
            x == "5"    true

===            x === 5        true        equal value and type
            x === "5"    false

!=            x != 8        true        not equal

!==            x !== 5        false        not equal value or not equal type
            x !== "5"    true
            x !== 8        true

>            x > 8        false        greater than

<            x < 8        true        less than

>=            x >= 8        false        greater than or equal to

<=            x <= 8        true        less than or equal to

less than equal to in javascript

| <= | less than or equal to |    x <= 8 | true |

=== javascript

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

// true
x === 5

// false
x === "5"

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

Có thể bạn đã miss một số snippets code

Lodash sort - Test performance with native js

Lodash sort - Bài viết ngắn gọn muốn đưa ra con số sau khi test về Lodash và Native js. Đây chỉ là check trên phương diện cá nhân...

using async/await to catch errors

parse javascript Example

The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string

Get value select option JavaScript

How do I get the text value of a selected option and get value select option by Jquery.

Fix google adsense làm web chậm!

Sủ dụng google adsense chắc chắn gây cho hệ thống web wordpress của bạn bị chậm rất nhiều. Điều đó là điều đương nhiên, và đây là cách khắc phục.