当前位置:网站首页>Explore the use of self increasing and self decreasing operators
Explore the use of self increasing and self decreasing operators
2022-07-25 22:24:00 【Ultimate xiaoteng】
List of articles
1. introduction
Increment operator ( ++ ) And decrement operators ( – )
To distinguish x++ and ++x So I write this article .
2. use JavaScript Code implementation
Self increasing operation
// Self increasing , Self increase means adding 1 Figures obtained
var x = 5;
x++;//x++ Equate to x = x + 1;
console.log(x);// The result is 6
// X++ And ++x There are two uses
var a1 =5 , a2 = 5 ;
var b;
var c;
b=a1++;
c=++a2;
console.log(b);// Output 5
console.log(c);// Output 6
console.log(a1);// Output 6
console.log(a2);// Output 6
Through the above code, we can find , Variable value is 5, No matter through Variable ++ still ++ Variable , The values of variables are added by themselves 1, But there are differences when assigning values to other variables in the process of self addition .
In fact, we don't need to know the underlying principle of the code , There is a rule to remember , Who is close to the right of the equal sign , Just use who .
for example ,s = x++ To the right of this equal sign is the variable , Then assign a value to the variable first ;( First use then add )s = ++x To the right of this equal sign is a plus sign , Then calculate self addition first , Get the result and assign value ;( Add first and then use )
The same is true of self subtraction
var x1 =9 , x2 = 9 ;
var y;
var z;
y=x1--;
z=--x2;
console.log(y);// Output 9
console.log(z);// Output 8
console.log(x1);// Output 8
console.log(x2);// Output 8
Who is close to the right of the equal sign , Just use who .s = x-- To the right of this equal sign is the variable , Then assign a value to the variable first .( Use first and then subtract )s = --x To the right of this equal sign is a minus sign , Then calculate self subtraction first , Get the result and assign value .( First reduce and then use )
3. Summary
The overall difference is - - -( Operation before use ) And - - -( Use first and then calculate ) The difference between .
Practice and you will be impressed .
边栏推荐
- 谷歌分析UA怎么转最新版GA4最方便
- How is it most convenient to open an account for stock speculation? Is it safe for online account managers to open an account
- MySQL - subquery - column subquery (multi row subquery)
- D3.js 学习
- 如何将一个域名解析到多个IP地址?
- IPv4地址已经完全耗尽,互联网还能正常运转,NAT是最大功臣!
- Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
- arcgis开发常用源码
- Selenium basic use and use selenium to capture the recruitment information of a website (continuously updating)
- SMART S7-200 PLC通道自由映射功能块(DO_Map)
猜你喜欢

The price of dividing gold bars

数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir

Usage of in in SQL DQL query

Flex layout

JMeter websocket interface test

Smart S7-200 PLC channel free mapping function block (do_map)

IPv4 addresses have been completely exhausted, and the Internet can work normally. NAT is the greatest contributor!

Selenium basic use and use selenium to capture the recruitment information of a website (continuously updating)

IPv4地址已经完全耗尽,互联网还能正常运转,NAT是最大功臣!

Method of converting MAPGIS format to ArcGIS
随机推荐
Gan, why '𠮷 𠮷'.Length== 3 ??
[assembly language 01] basic knowledge
Perform Jieba word segmentation on the required content and output EXCEL documents according to word frequency
H5 lucky scratch lottery free official account + direct operation
MySQL --- 子查询 - 列子查询(多行子查询)
Playwright tutorial (I) suitable for Xiaobai
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No suc
【数据库学习】Redis 解析器&&单线程&&模型
Wechat applet (anti shake, throttling), which solves the problem that users keep pulling down refresh requests or clicking buttons to submit information; Get the list information and refresh the data
分割金条的代价
Imitation Tiktok homepage interface
[go basics 02] the first procedure
Don't know mock test yet? An article to familiarize you with mock
6-18 vulnerability exploitation - backdoor connection
JSP nine built-in objects
Output Yang Hui triangle with two-dimensional array
C language: random generated number + selective sorting
Use of hyperlinks
How is it most convenient to open an account for stock speculation? Is it safe for online account managers to open an account
QML module not found