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?.
setTimeout allows us to run a function once after the interval of time. setInterval allows us to run a function repeatedly, starting after the interval of time, then repeating continuously at that interval.
The only difference is , setTimeout() triggers the expression only once while setInterval() keeps triggering expression regularly after the given interval of time. (unless you tell it to stop). To stop further calls, we should call clearInterval(timerId) .
setTimeout(function, milliseconds ) Executes a function, after waiting a specified number of milliseconds. setInterval(function, milliseconds ) Same as setTimeout(), but repeats the execution of the function continuously.
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
.
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