掌握某个javascript功能背后的概念

时间:2016-03-24 07:53:03

标签: javascript

我在互联网上找到了这个脚本,我非常想了解它。我知道我可能会得到负面投票,但我真的希望看到这个功能在评估当前世界人口方面的作用方式,特别是使用脚本中选择的值以及每个值背后的原因。我很感激你的帮助。

<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>

1 个答案:

答案 0 :(得分:3)

代码说的是这样的:
1996年1月1日世界人口为56亿。 据推测,明年,1997年1月1日,它是56.9亿。 根据该数据,代码试图将人口增长推断到现在,假设5690000000 - 5600000000为年人口增量。