当前位置:网站首页>Easy to understand, distinguish between ++i and I++
Easy to understand, distinguish between ++i and I++
2022-07-27 16:06:00 【Moving maple】
The most frequently used is i++ This variable increases by itself 1 In the form of . In fact, if it's just for variables i Self increasing 1 Words ,i++ and ++i The effect is the same .
var a = 1;
a++;
console.log(a) // 2
var b = 1;
++b;
console.log(b) // 2
··························································
But when it is necessary operation when ,i++ and ++i It makes a big difference .
··························································
var c = 1;
var result1 = c++ + 2;
console.log(result1) // 3
// The usual explanation :c Participate in the operation and then increase
// My explanation : That's true , But it can be understood that , Big guy Jean c Go and 2 Engage in war ( operation )
// Then fight ( operation ) After finishing , promote c Level of ( Self increasing 1).
var d = 1;
var result2 = ++d + 2;
console.log(result2) // 4
// The usual explanation :d First increase and then participate in the operation
// My explanation : That's true , But it can be understood that , Big guy Jean d Go and 2 Engage in war ( operation ),
// And let d Upgrade level ( Self increasing 1) I'll talk to you later 2 Against the , Or you won't be able to fight .
边栏推荐
- 解决openwrt package目录下多个文件夹重名编译警告(call subdir 函数)
- Scratch crawler framework
- C language: string function and memory function
- C语言实现字节流与十六进制字符串的相互转换
- [sword finger offer] interview question 45: arrange the array into the smallest number
- 三星关闭在中国最后一家手机工厂
- Constraints, design and joint query of data table -- 8000 word strategy + Exercise answers
- C language realizes the conversion between byte stream and hexadecimal string
- Paper_Book
- C language: custom type
猜你喜欢

Openwrt adds RTC (mcp7940 I2C bus) drive details

Scratch crawler framework

Embedded development: tips and techniques -- seven techniques to meet the real-time deadline

Determine the exact type of data

Using Lombok results in the absence of parent class attributes in the printed toString

使用transform:translate()出现内容模糊问题

Openwrt adds support for SD card

Openwrt增加对 sd card 支持

Understand │ what is cross domain? How to solve cross domain problems?

CAS比较交换的知识、ABA问题、锁升级的流程
随机推荐
初识MySQL数据库
Talk about the index of interview questions
C: On function
项目优化个人感悟
网络设备硬核技术内幕 路由器篇 22
Constraints, design and joint query of data table -- 8000 word strategy + Exercise answers
Single machine high concurrency model design
MySQL表数据的增删查改
Busybox login: can't execute'/bin/bash': no such file or directory solution
C language: custom type
Half find
传音控股披露被华为起诉一事:已立案,涉案金额2000万元
openwrt 编译驱动模块(在openwrt源代码外部任意位置编写代码,独立模块化编译.ko)
数据表的约束以及设计、联合查询——8千字攻略+题目练习解答
juc包下常用工具类
Breaking through soft and hard barriers, Xilinx releases Vitis unified software platform for developers
使用transform:translate()出现内容模糊问题
DRF学习笔记(一):数据序列化
[sword finger offer] interview question 54: the k-largest node of the binary search tree
单机高并发模型设计