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 assignment operators of javascript

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

Share

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

This article mainly introduces "what are the assignment operators of javascript". In the daily operation, I believe many people have doubts about the assignment operators of javascript. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the assignment operators of javascript?" Next, please follow the editor to study!

The assignment operators of javascript are: "=", "+ =", "- =", "* =", "/ =", "% =", "=", "> =", "& =", "| =", "^ =".

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

In javascript, the assignment operator is used to assign values to variables. The Operand to the left of the assignment operator must be a variable, object attribute, or array element, also known as a left value.

For example, the following is incorrect because the value on the left is a fixed value and operation is not allowed.

1 = 100; / / an error is returned

Assignment operations have the following two forms:

Simple assignment =: copy the value of the Operand on the right of the equal sign directly to the Operand on the left, so the value of the Operand on the left will change.

Assignment operation of additional operation: perform some operation on the right Operand before assignment, and then copy the result to the left Operand. The details are shown in the table:

The assignment operator assignment operator description of the additional operation is equivalent to + = addition operation or join operation and assign a + = ba= a + b color = subtraction operation and assign a-= ba= a-bbank = multiplication operation and assign a * = ba= a * b move = division operation and assign a / = ba= a / b% = modular operation and assign a% = ba= a% > b > Value bit a > = ba = a > > bounded = bit and operation and assignment a & = ba = a & b | = bit or operation and assignment a | = ba = a | = b ^ = bit XOR operation and assignment a ^ = ba = a ^ b

The sample code is as follows:

Var x = 10 x + = 20 console.log (x); / / output: 30var x = 12, y = 7 x-= y position console.log (x); / / output: 5x = 5x x * = 25 position console.log (x); / / output: 125x = 50 scape x / = 10 position console.log (x); / / output: 5x = 100th x% = 15scape console.log (x) / / output: 10 at this point, the study of "what are the assignment operators of javascript" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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