What are the javascript operators?
Operators include: 1. Arithmetic operators, including " ", "-", "*", etc.; 2. Assignment operators, including "=", "=", "-=", etc.; 3. , Comparison operators, including "==", "===", etc.; 4. Logical operators, including "&&", "||", etc.; 5. Bit operators, including "&", "|", etc. .
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
JavaScript operator (operator)
In JavaScript, operators are used to assign values, compare values, perform arithmetic operations, etc.
Arithmetic operators
Arithmetic operators are used to perform operations on two variables or values.
Assign y = 5, the following table will explain to you the use of arithmetic operators:
Operator | Description | Example | y value | x value |
---|---|---|---|---|
Addition | x = y 2 | y = 5 | #x = 7 | |
- | Subtraction | x = y - 2 | y = 5 | #x = 3 |
* | Multiplication | x = y * 2 | y = 5 | #x = 10 |
/ | Division | x = y / 2 | y = 5 | x = 2.5 |
remainder | x = y % 2 | y = 5 | x = 1 | |
increment | x = y | y = 6 | x = 6 | |
y = 6 | #x = 5 | |||
decrement | x = --y | y = 4 | x = 4 | |
y = 4 | x = 5 |
Assignment operator
The assignment operator is used to assign values to JavaScript variables. Given x=10 and y=5, the following table explains the assignment operators:Example | Instance | x Value | |
---|---|---|---|
x = y | x = y | x = 5 | |
x = y | x = x y | #x = 15 | |
x -= y | x = x - y | x = 5 | |
x *= y | x = x * y | x = 50 | |
x /= y | x = x / y | x = 2 | |
x %= y | x = x % y | x = 0 |
operator, = operator can be used to concatenate strings.
Given text1 = "Good ", text2 = "Morning", and text3 = "", the following table explains the use of string operators:
Example | text1 | #text2 | text3 | |
---|---|---|---|---|
text3 = text1 text2 | "Good " | "Morning" | "Good Morning" | |
text1 = text2 | "Good Morning" | "Morning" | "" |
Comparison operators are used to judge logical statements to determine whether two given values or variables are equal.
Given x=5, the following table shows the use of comparison operators:
Description | Comparison | The result | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is equal to | x == 8 | false | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
true | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The value and type are equal (constantly equal to ) | x === "5" | false | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
true | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
is not equal to | x != 8 | true | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The value and type are not equal (not equal) | x !== "5" | true | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
false | ##> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x > 8 | false | < | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x < 8 | true | ##> = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x>= 8 | false | <= | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x <= 8 | true | Conditional operator The conditional operator is used for assignment operations based on conditions. Given x=6 and y=3, the following table demonstrates the operation of the conditional operator:
Logical operator Logical operators are used to determine the logical relationship between variables or values. Given x=6 and y=3, the following example demonstrates the use of logical operators:
##Bitwise operator Bit operators work on 32-bit numbers. Any numeric operations will be converted to 32 bits. The result is converted to a JavaScript number.
The above is the detailed content of What are the javascript operators?. For more information, please follow other related articles on the PHP Chinese website! Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
![]() Hot AI Tools![]() Undresser.AI UndressAI-powered app for creating realistic nude photos ![]() AI Clothes RemoverOnline AI tool for removing clothes from photos. ![]() Undress AI ToolUndress images for free ![]() Clothoff.ioAI clothes remover ![]() Video Face SwapSwap faces in any video effortlessly with our completely free AI face swap tool! ![]() Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Assassin's Creed Shadows - How To Find The Blacksmith And Unlock Weapon And Armour Customisation
4 weeks ago
By DDD
Roblox: Dead Rails - How To Complete Every Challenge
3 weeks ago
By DDD
![]() Hot Tools![]() Notepad++7.3.1Easy-to-use and free code editor ![]() SublimeText3 Chinese versionChinese version, very easy to use ![]() Zend Studio 13.0.1Powerful PHP integrated development environment ![]() Dreamweaver CS6Visual web development tools ![]() SublimeText3 Mac versionGod-level code editing software (SublimeText3) ![]() Hot Topics
CakePHP Tutorial
![]() ![]() ![]() How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system. ![]() WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology ![]() The += operator is used to add the value of the left operand to the value of the right operand and assign the result to the left operand. It is suitable for numeric types and the left operand must be writable. ![]() JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We ![]() JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest ![]() Python is widely used in a wide range of fields with its simple and easy-to-read syntax. It is crucial to master the basic structure of Python syntax, both to improve programming efficiency and to gain a deep understanding of how the code works. To this end, this article provides a comprehensive mind map detailing various aspects of Python syntax. Variables and Data Types Variables are containers used to store data in Python. The mind map shows common Python data types, including integers, floating point numbers, strings, Boolean values, and lists. Each data type has its own characteristics and operation methods. Operators Operators are used to perform various operations on data types. The mind map covers the different operator types in Python, such as arithmetic operators, ratio ![]() Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service ![]() There are many operators in Go language, which are often used to perform various mathematical and logical operations. Each operator has its own precedence, which determines the order in which they are evaluated in an expression. This article will introduce you to the priority ranking of operators in the Go language and find out the operator with the highest priority. The operators in Go language are as follows in order from high to low precedence: parentheses: (). Parentheses are used to change the precedence order of operators. Parentheses in expressions are evaluated first. Unary operators: +, -, !. Unary operator means that only one ![]() |