当前位置:网站首页>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
边栏推荐
- Two-stage RO: part 1
- 连表查询 select 生成
- The principle and related problems of acid in MySQL
- 20220215-ctf-misc-buuctf-ningen--binwalk analysis --dd command separation --archpr brute force cracking
- ArrayList分析1-循环、扩容、版本
- Wechat official account development (1) introduction to wechat official account
- C#生成putty格式的ppk文件(支持passphrase)
- A single element in an ordered array
- Some views on libco
- HDU 2488 A Knight's Journey(DFS)
猜你喜欢

CentOS install MySQL

Two-stage RO: part 1

20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute

Authentication principle of Ranger plug-in

C#生成putty格式的ppk文件(支持passphrase)

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

Oracle-数据完整性

Implementation of OSD on Hisilicon platform (1)

Can JDBC based on openjdk connect to MySQL?

HDU 2488 A Knight's Journey(DFS)
随机推荐
C WinForm program interface optimization example
ArrayList分析1-循环、扩容、版本
left join左连接匹配数据为NULL时显示指定值
Two-stage RO: part 1
Redis - sentinel mode
2022 is half way through. It's hard to make money
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
Simple application example of rhai script engine
20220216 misc buuctf another world WinHex, ASCII conversion flag zip file extraction and repair if you give me three days of brightness zip to rar, Morse code waveform conversion mysterious tornado br
[daily record] - bug encountered in BigDecimal division operation
优质的水泵 SolidWorks模型素材推荐,不容错过
Stack frame
2022-2028 global weight loss ginger tea industry research and trend analysis report
P4学习——p4runtime
CSDN常用复杂公式模板记录
P4学习——Basic Tunneling
History of deep learning
leetcode 474. Ones and zeroes (medium)
Docsify building a personal minimalist knowledge warehouse
How to specify the number of cycles in JSTL- How to loop over something a specified number of times in JSTL?