Question

I am making a script that checks to see if a server is connected or has gone away.While looking around how others have done it,i realized that some are using hex inside the function.For instance setInterval(l,6E4)

Another example

setTimeout(function(){d(window.checknet.config.checkURL)},window.checknet.config.checkInterval)}a=a||{};a.checkURL=a.checkURL||window.location.href;a.checkInterval=a.checkInterval||5E3;a.warnMsg=a.msg||"No Internet connection detected, disabled features will be re-enabled when a connection is detected. ";

This is the use of hex a.checkInterval=a.checkInterval||5E3;

Why is hex being used instead of ordinary decimal figures?.

Was it helpful?

Solution

That is not hex, its a number written in Scientific Notation, 6 x 104.

= 60.000

As the time of setInterval is in milliseconds, if you want to use an integer as seconds, it's easy to use it like: Ne3 being N = seconds.

1e3 = 1000 = 1 second

Edit:

Hex numbers are written with the prefix 0x.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top