22 lines
379 B
Markdown
22 lines
379 B
Markdown
importance: 4
|
|
|
|
---
|
|
|
|
# Which values shows the while?
|
|
|
|
For every loop, write down which values it shows, in your opinion. And then compare with the answer.
|
|
|
|
Both loops `alert` same values or not?
|
|
|
|
1. The prefix form `++i`:
|
|
|
|
```js
|
|
let i = 0;
|
|
while (++i < 5) alert( i );
|
|
```
|
|
2. The postfix form `i++`
|
|
|
|
```js
|
|
let i = 0;
|
|
while (i++ < 5) alert( i );
|
|
```
|