Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the operators in javascript and how to use them

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you what operators in javascript and how to use the relevant knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

Operator has: 1, arithmetic operators, including "+", "-", "*", etc.; 2, assignment operators, including "=", "+ =", "- =", etc.; 3, comparison operators, including "= =", "=", etc.; 4, logical operators, including "& &", "| |", etc.; 5, bit operators, including "&", "|" and so on.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

JavaScript operator (operator)

In JavaScript, operators are used to assign, compare values, perform arithmetic operations, and so on.

Arithmetic operator

Arithmetic operators are used to perform operations on two variables or values.

Assign y = 5, the following table will show you the use of arithmetic operators:

Operator description example y value x value + addition x = y + 2y = 5x = 7-subtraction x = y-2y = 5x = 3* multiplication x = y * 2y = 5x = 10 / division x = y / 2y = 5x = 2.5% remainder x = y% 2y = 5x = 1x + + yy = 6x = 6x = y yield y = 6x = 5color-minus x =-yy = 4x = 4x = yMerry y = 4x = 5

Assignment operator

The assignment operator is used to assign values to JavaScript variables.

The following table explains the assignment operator given xexamples 10 and ytrees 5:

The operator example example x value = x = yx = yx = 5 percent percent x + = yx = x + yx = 15 accoutrements x-= yx = x-yx = 5 percent percent x * = yx = x * yx = 50 Universe x / = yx = x / yx = 2% yx = x% yx = 0

String operator

+ operator, and the + = operator can be used to concatenate strings.

Given text1 = "Good", text2 = "Morning", and text3 = "", the following table explains the use of string operators:

Operator example text1text2text3+text3 = text1 + text2 "Good"Morning"Good Morning" + = text1 + = text2 "Good Morning"Morning"

Comparison operator

The comparison operator is used in the judgment of logical statements to determine whether two given values or variables are equal.

Given xcompare 5, the following table shows the use of the comparison operator:

Operator description comparison result = = equal to x = = 8falsex = = 5 trueworthy equal = equal (always equal) x = "5" falsex = 5 trueworthy = not equal to x! = 8 trueworthy equal = unequal (not equal to) x! = "5" truex! = = 5false > greater than x > 8false= greater than or equal to x > = 8false > 100102 is all the content of this article "what are the operators in javascript and how to use them? thank you for reading!" I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report