JavaScript | Tricky Output | SCOPE | IIFE

Have you guessed it?
.
.
.
Let’s see…
Answer
The following code will write the value 10
times.

What if I want values from 0-9
in the console?
There are different ways to achieve this.
By using IIFE
- IIFE is Immediately Invoked Function Expressions.
- By using IIFE’s we can also scope the value of the variable
i
to print the current index, instead of printing the final value as10
.


There is another way to fix this issue using ES6 syntax
