当前位置:网站首页>Detailed analysis of operators i++ and ++i in JS, i++ and ++i
Detailed analysis of operators i++ and ++i in JS, i++ and ++i
2022-07-01 00:58:00 【imkaifan】
let i = 1,o = 1;
let k = i++;
let j = ++o;
console.log(k,i) //1 2 ( after ++) First assign yourself to k, And then I'll do it myself ++
console.log(j,o) //2 2 ( First ++) First execute yourself ++ operation , Then assign the result to j
i++ It returns the value before autoincrement ,++i The returned value is the self incremented value i++ Good ++i In fact, it is an expression , An expression always returns a value
let a = 10,b = 20,c = 30;
++a; // 11 ++a You mean for a=a+1 a by 11, At this time, the operation priority is not involved .
a++; // 12 a++ You mean for a=a+1 a by 12 , At this time, the problem of operation priority is still not involved .
e = ++a + ++b + c++ + a++; // 13 + 21 + 30 + 13 = 77( His writing , It belongs to a mistake )
// Correct explanation
// At this point, we must consider the problem of operation level
// ++a a First of all +1 Then assign the value to the result :13 a=13
// ++b b First of all +1 Then assign the value to the result :21 b=21
// c++ First the c Value is assigned to the result :30 c own +1 c=31
// a++ First the a value 13 Assign results :13 a own +1 a=14
console.log(e) // 77
边栏推荐
- C # generates PPK files in putty format (supports passphrase)
- Excuse me, does Flink support synchronizing data to sqlserver
- Can JDBC based on openjdk connect to MySQL?
- 2022-2028 global mobile scanning radiology room industry survey and trend analysis report
- Sword finger offer 18 Delete the node of the linked list
- SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
- left join左连接匹配数据为NULL时显示指定值
- 最长的可整合子数组的长度
- Using Excel to quickly generate SQL statements
- Sword finger offer 19 Regular Expression Matching
猜你喜欢
C # generates PPK files in putty format (supports passphrase)
[daily record] - bug encountered in BigDecimal division operation
2022-2028 global ethylene oxide scrubber industry research and trend analysis report
Cmu15445 (fall 2019) project 1 - buffer pool details
MySQL variables, stored procedures and functions
Implementation of OSD on Hisilicon platform (1)
2022-2028 global PTFE lined valve industry research and trend analysis report
20220215 CTF misc buuctf the world in the mirror the use of stegsolve tool data extract
P4学习——Basic Tunneling
写给 5000 粉丝的一封信!
随机推荐
2022 is half way through. It's hard to make money
IBL预计算的疑问终于解开了
【日常记录】——对BigDecimal除法运算时遇到的Bug
【原创】 PLSQL 索引排序优化
NE555 waveform generator handle tutorial NE555 internal structure (I)
Search rotation sort array
实验八 T-sql,存储过程
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
深度学习的历史
C # generates PPK files in putty format (supports passphrase)
Luogu p1168 median
JS bubble sort and select sort
Get to know the drawing component of flutter - custompaint
Multi graph explanation of resource preemption in yarn capacity scheduling
Redis based distributed lock
From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years
CSDN常用复杂公式模板记录
2022-2028 global electric yacht industry research and trend analysis report
Redis - understand the master-slave replication mechanism
优质的水泵 SolidWorks模型素材推荐,不容错过