我正在制作一个脚本来检查服务器是否已连接或已消失。在查看其他人如何完成此操作时,我意识到有些人在函数内使用十六进制。例如 setInterval(l ,6E4)
另一个例子
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. ";
这是十六进制的使用a.checkInterval=a.checkInterval||5E3;
为什么使用十六进制而不是普通的十进制数字?
最佳答案
这不是十六进制,它是用 Scientific Notation 写的数字,6 x 104。
= 60.000
由于setInterval
的时间单位是毫秒,如果你想使用整数
作为秒,很容易使用它,如下所示: Ne3
为 N = 秒
。
1e3 = 1000 = 1 second
<小时/>
编辑:
十六进制数字以前缀0x
书写。
关于jquery - 在jquery的setInterval()和setTimeout()中使用十六进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21277958/