当前位置:网站首页>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
边栏推荐
- 2022-2028 global rotary transmission system industry research and trend analysis report
- 魔王冷饭||#101 魔王解惑数量多与质量;员工管理;高考志愿填报;游戏架构设计
- left join左连接匹配数据为NULL时显示指定值
- 什么是产品思维
- 最长的可整合子数组的长度
- 2022-2028 global plant peptone industry research and trend analysis report
- A single element in an ordered array
- The principle and related problems of acid in MySQL
- ArrayList analysis 1-cycle, capacity expansion, version
- 1009 product of polynomials (25 points) [PTA class A]
猜你喜欢

2022-2028 global public address fire alarm system industry research and trend analysis report

2022-2028 global encrypted external hard disk industry research and trend analysis report

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

Bugku CTF daily one question dark cloud invitation code

CTF tool (1) -- archpr -- including installation / use process

C WinForm program interface optimization example

2022-2028 global mobile scanning radiology room industry survey and trend analysis report

The principle of journal node

Date类的实现

NE555 waveform generator handle tutorial NE555 internal structure (I)
随机推荐
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
获取屏幕高度
ArrayList分析1-循环、扩容、版本
Deployment of mini version message queue based on redis6.0
"Experience" my understanding of user growth "new users"
Docsify building a personal minimalist knowledge warehouse
Two-stage RO: part 1
[untitled]
Can SQL execution be written in tidb dashboard
Implementation of OSD on Hisilicon platform (1)
ArrayList analysis 1-cycle, capacity expansion, version
Sword finger offer 19 Regular Expression Matching
Exercise and health
ArrayList分析1-循环、扩容、版本
Rust controls Dajiang programmable UAV Tello
Pytorch auto derivation
Can JDBC based on openjdk connect to MySQL?
2022-2028 global capsule shell industry research and trend analysis report
Problem solving: how to manage thread_local pointer variables
Get screen height