当前位置:网站首页>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
边栏推荐
- [daily record] - bug encountered in BigDecimal division operation
- The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
- Oracle temporary table explanation
- left join左连接匹配数据为NULL时显示指定值
- Introduction to ES6 promise, new features of ES7 and es8 async and await
- Line number of Jenkins pipeline script execution exception
- Rhai - rust's embedded scripting engine
- C # generates PPK files in putty format (supports passphrase)
- Longest valid bracket
- [untitled]
猜你喜欢

Redis - how to understand publishing and subscribing

2022-2028 global single travel industry research and trend analysis report

魔王冷饭||#101 魔王解惑数量多与质量;员工管理;高考志愿填报;游戏架构设计

20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking

Implementation of date class

2022-2028 global herbal diet tea industry research and trend analysis report

Ranger plug-in development (Part 2)

Oracle临时表详解

Line number of Jenkins pipeline script execution exception

Pytorch auto derivation
随机推荐
[daily record] - bug encountered in BigDecimal division operation
2022-2028 global electric yacht industry research and trend analysis report
初识 Flutter 的绘图组件 — CustomPaint
Confirm() method of window
Using Excel to quickly generate SQL statements
2022-2028 global encrypted external hard disk industry research and trend analysis report
Exercise and health
CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
Excuse me, does Flink support synchronizing data to sqlserver
2022-2028 global plant peptone industry research and trend analysis report
File reading and writing for rust file system processing - rust Practice Guide
Oracle table creation and management
2022 is half way through. It's hard to make money
Interface documentation system - Yapi
Luogu p1168 median
连表查询 select 生成
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
HDU 2488 A Knight's Journey(DFS)
CTF tool (1) -- archpr -- including installation / use process
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report