Roadmap to becoming a developer in 2022
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

21 lines
553 B

As the name says, the increment operator increases the value of a variable by **1**. There are two types of increment operators: `pre-increment` and `post-increment`.
## Pre-increment
The pre-increment operator increases the value of a variable by 1 and then returns the value. For example:
```js
let x = 1;
console.log(++x); // 2
console.log(x); // 2
```
## Post-increment
The post-increment operator returns the value of a variable and then increases the value by 1. For example:
```js
let x = 1;
console.log(x++); // 1
console.log(x); // 2
```