掌握某个javascript功能背后的概念
Grasping the concept behind a certain javascript functionality
我在互联网上找到了这个脚本,我非常想了解它。我知道我可能会得到负面的投票,但我真的希望了解这个功能在估计当前世界人口方面的工作方式,特别是脚本中选择的值以及每个值背后的原因。如果有任何帮助,我将不胜感激。
<body>
<script type="text/javascript">
function maind() {
startdate = new Date()
now(startdate.getYear(), startdate.getMonth(), startdate.getDate(), startdate.getHours(), startdate.getMinutes(), startdate.getSeconds())
}
function ChangeValue(number, pv) {
numberstring = ""
var j = 0
var i = 0
while (number > 1) {
numberstring = (Math.round(number - 0.5) % 10) + numberstring
number = number / 10
j++
if (number > 1 && j == 3) {
numberstring = "," + numberstring
j = 0
}
i++
}
numberstring = numberstring
if (pv == 1) {
document.getElementById("worldpop").innerHTML = numberstring
}
}
function now(year, month, date, hours, minutes, seconds) {
startdatum = new Date(year, month, date, hours, minutes, seconds)
var now = 5600000000.0
var now2 = 5690000000.0
var groeipercentage = (now2 - now) / now * 100
var groeiperseconde = (now * (groeipercentage / 100)) / 365.0 / 24.0 / 60.0 / 60.0
nu = new Date()
schuldstartdatum = new Date(96, 1, 1)
secondenoppagina = (nu.getTime() - startdatum.getTime()) / 1000
totaleschuld = (nu.getTime() - schuldstartdatum.getTime()) / 1000 * groeiperseconde + now
ChangeValue(totaleschuld, 1);
timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours(),startdatum.getMinutes(),startdatum.getSeconds())", 200)
}
window.onload = maind
</script>
Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>.
</body>
代码显示如下内容:
1996年1月1日,世界人口为56亿。明年,大概是1997年1月1日,它是5690000000。基于这些数据,该代码试图推断到目前为止的人口增长,假设5690000000 - 5600000000
是每年的人口增量。
相关文章:
- 添加文字和评论功能更新Div
- JavaScript打印功能使日历停止工作
- 每当您在选择器内移动鼠标时,悬停功能就会重复
- 如何防止网页加载后自动启动功能
- 除修剪外的其他功能
- 悬停功能触发器
- 使用angularjs向浏览器发送servlet响应(下载功能)
- 删除CKEditor工具栏按钮,但不删除功能
- 异步facebook功能
- 如何将chrome扩展功能移植到移动设备(特别是jquery和trello)
- 代码背后调用一个JavaScript函数的按钮点击-C#
- jQuery滚动功能只工作一次
- Graphiti中是否有任何工具提示功能
- React redux初始化功能,无论状态变化如何
- 在哪里可以学习ECMAScript标准中尚未包含的JavaScript功能
- 正在获取select上的功能id
- Rhino打印功能
- 使用(navigator.geolocation)检测浏览器功能错误
- 主体单击删除功能上的输入框宽度
- 掌握某个javascript功能背后的概念