Hướng dẫn what are the different operators in javascript? - các toán tử khác nhau trong javascript là gì?

JavaScript bao gồm các toán tử giống như các ngôn ngữ khác. Một toán tử thực hiện một số hoạt động trên một hoặc nhiều toán hạng (giá trị dữ liệu) và tạo ra kết quả. Ví dụ, trong ____99, dấu

var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
0 là một toán tử và 1 là toán hạng bên trái và 2 là toán hạng bên phải. Toán tử
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
0 thực hiện việc bổ sung hai giá trị số và trả về kết quả.

Show

 operator 

 operator

JavaScript bao gồm các loại nhà khai thác sau đây.

  1. Toán tử số học
  2. Toán tử so sánh
  3. Toán tử logic
  4. Toán tử chuyển nhượng
  5. Toán tử có điều kiện
  6. Toán tử ternary

Toán tử số học

Các toán tử số học được sử dụng để thực hiện các hoạt động toán học giữa các toán hạng số.

Nhà điều hành Sự mô tả
+ Thêm hai toán hạng số.
- Trừ toán hạng bên phải từ toán hạng bên trái
* Nhân hai toán hạng số.
/ Chia hạng bên trái cho toán hạng bên phải.
Phần trăm Toán tử mô đun. Trả lại phần còn lại của hai toán hạng.
++ Toán tử gia tăng. Tăng giá trị toán hạng lên một.
- Toán tử giảm. Giảm giá trị của một.

Ví dụ sau đây cho thấy cách các toán tử số học thực hiện các tác vụ khác nhau trên toán hạng.

var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1

Các toán tử

var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
2 và
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
3 là các toán tử đơn. Nó chỉ hoạt động với toán hạng bên trái hoặc phải. Khi được sử dụng với toán hạng bên trái, ví dụ:
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
4, nó sẽ tăng giá trị của
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
5 khi điều khiển chương trình chuyển sang câu lệnh tiếp theo. Theo cách tương tự, khi nó được sử dụng với toán hạng bên phải, ví dụ,
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
6, nó sẽ tăng giá trị của
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
5 chỉ có. Do đó,
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
4 được gọi là sau khi tăng cường và
var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
6 được gọi là trước khi tăng.

var x = 5;

x++; //post-increment, x will be 5 here and 6 in the next line

++x; //pre-increment, x will be 7 here  

x--; //post-decrement, x will be 7 here and 6 in the next line

--x; //pre-decrement, x will be 5 here

Kết hợp chuỗi

Toán tử

var x = 5, y = 10;

var z = x + y; //performs addition and returns 15

z = y - x; //performs subtraction and returns 5

z = x * y; //performs multiplication and returns 50

z = y / x; //performs division and returns 2

z = x % 2; //returns division remainder 1
0 thực hiện thao tác nối khi một trong các toán hạng thuộc loại chuỗi. Ví dụ sau đây cho thấy sự kết hợp chuỗi ngay cả khi một trong các toán hạng là một chuỗi.

var a = 5, b = "Hello ", c = "World!", d = 10;

a + b; //returns "5Hello "

b + c; //returns "Hello World!"

a + d; //returns 15

b + true; //returns "Hello true"

c - b; //returns NaN; - operator can only used with numbers

Toán tử so sánh

JavaScript cung cấp các toán tử so sánh so sánh hai toán hạng và trả về giá trị boolean

var x = 5;

x++; //post-increment, x will be 5 here and 6 in the next line

++x; //pre-increment, x will be 7 here  

x--; //post-decrement, x will be 7 here and 6 in the next line

--x; //pre-decrement, x will be 5 here
1 hoặc
var x = 5;

x++; //post-increment, x will be 5 here and 6 in the next line

++x; //pre-increment, x will be 7 here  

x--; //post-decrement, x will be 7 here and 6 in the next line

--x; //pre-decrement, x will be 5 here
2.

Người vận hành Sự mô tả
+ Thêm hai toán hạng số.
- Trừ toán hạng bên phải từ toán hạng bên trái
* Nhân hai toán hạng số.
/ Chia hạng bên trái cho toán hạng bên phải.
Phần trăm Toán tử mô đun. Trả lại phần còn lại của hai toán hạng.
++ Toán tử gia tăng. Tăng giá trị toán hạng lên một.
- Toán tử giảm. Giảm giá trị của một.

Ví dụ sau đây cho thấy cách các toán tử số học thực hiện các tác vụ khác nhau trên toán hạng.

var a = 5, b = 10, c = "5";
var x = a;

a == c; // returns true

a === c; // returns false

a == x; // returns true

a != b; // returns true

a > b; // returns false

a < b; // returns true

a >= b; // returns false

a <= b; // returns true

Các toán tử var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 2 và var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 3 là các toán tử đơn. Nó chỉ hoạt động với toán hạng bên trái hoặc phải. Khi được sử dụng với toán hạng bên trái, ví dụ: var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 4, nó sẽ tăng giá trị của var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 5 khi điều khiển chương trình chuyển sang câu lệnh tiếp theo. Theo cách tương tự, khi nó được sử dụng với toán hạng bên phải, ví dụ, var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 6, nó sẽ tăng giá trị của var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 5 chỉ có. Do đó, var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 4 được gọi là sau khi tăng cường và var x = 5, y = 10; var z = x + y; //performs addition and returns 15 z = y - x; //performs subtraction and returns 5 z = x * y; //performs multiplication and returns 50 z = y / x; //performs division and returns 2 z = x % 2; //returns division remainder 1 6 được gọi là trước khi tăng.

Kết hợp chuỗi

Nhà điều hành Sự mô tả
+ Thêm hai toán hạng số.
- Trừ toán hạng bên phải từ toán hạng bên trái
* Nhân hai toán hạng số.

var a = 5, b = 10;

(a != b) && (a < b); // returns true

(a > b) || (a == b); // returns false

(a < b) || (a == b); // returns true

!(a < b); // returns false

!(a > b); // returns true

/

Chia hạng bên trái cho toán hạng bên phải.

Phần trăm Sự mô tả
+ Thêm hai toán hạng số.
- Trừ toán hạng bên phải từ toán hạng bên trái
* Nhân hai toán hạng số.
/ Chia hạng bên trái cho toán hạng bên phải.
Phần trăm Toán tử mô đun. Trả lại phần còn lại của hai toán hạng.
++ Toán tử gia tăng. Tăng giá trị toán hạng lên một.

var x = 5, y = 10, z = 15;

x = y; //x would be 10

x += 1; //x would be 6

x -= 1; //x would be 4

x *= 5; //x would be 25

x /= 5; //x would be 1

x %= 2; //x would be 1

Toán tử ternary

-

 ?  : ;

Toán tử giảm. Giảm giá trị của một.

var a = 10, b = 5;

var c = a > b? a : b; // value of c would be 10
var d = a > b? b : a; // value of d would be 5

  1. JavaScript bao gồm các toán tử thực hiện một số hoạt động trên một hoặc nhiều toán hạng (giá trị dữ liệu) và tạo ra kết quả.
  2. JavaScript bao gồm các loại toán tử khác nhau: toán tử số học, toán tử so sánh, toán tử logic, toán tử chuyển nhượng, toán tử có điều kiện.
  3. Toán tử ternary?: Là một dạng ngắn của điều kiện if-else.

Bạn muốn kiểm tra xem bạn biết JavaScript bao nhiêu?

Toán tử logic ..

Các nhà khai thác bitwise ...
Toán tử số học ..
Các nhà khai thác ternary ..
Toán tử logic ..
Người vận hành chuyển nhượng ..
Các nhà khai thác ternary ..
Toán tử loại ..

4 loại toán tử JavaScript là gì?

Có nhiều loại toán tử JavaScript khác nhau:..
Toán tử số học ..
Người vận hành chuyển nhượng ..
Toán tử so sánh..
Toán tử logic ..
Người vận hành có điều kiện ..
Loại người vận hành ..

7 toán tử JavaScript phổ biến nhất là gì?

Đây là những nhà khai thác khác nhau mà JavaScript hỗ trợ:..
Toán tử số học ..
Người vận hành chuyển nhượng ..
Toán tử chuỗi ..
Toán tử so sánh..
Toán tử logic ..
Các nhà khai thác bitwise ..
Các nhà khai thác đặc biệt ..

7 loại toán tử là gì?

Trong Python, có bảy loại toán tử khác nhau: toán tử số học, toán tử chuyển nhượng, toán tử so sánh, toán tử logic, toán tử nhận dạng, toán tử thành viên và toán tử Boolean.arithmetic operators, assignment operators, comparison operators, logical operators, identity operators, membership operators, and boolean operators.