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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With