Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What number does 8e3 evaluate to?

Tags:

I encountered this code today:

b = setTimeout(function () {
    // do some javascript stuff here
}, 8e3)

The timeout is set to 8e3. What time does this equate to in milliseconds, and why would anyone choose this strange notation? The code appears to be fully functional.

like image 476
Ryre Avatar asked Feb 07 '12 17:02

Ryre


1 Answers

8e3 is eight times ten to the power of three, that is, 8000. This is called scientific (or exponential) notation. Just imagine the "e" stands for "*10^".

In this case there isn't much point in using that notation, but once you start getting to larger numbers, exponential notation becomes more readable. To figure out how much "1000000000" is you'd have to count zeros, but 1e9 is immediately obvious.

like image 93
Matti Virkkunen Avatar answered Oct 21 '22 00:10

Matti Virkkunen