日期:2014-05-16  浏览次数:20430 次

Javascript中的~和~~

<script type="text/javascript">
        //  ~
        var testData = -2.9;
        var testResult = (typeof testData === "number" && !isNaN(testData) && testData !== Infinity) ? (testData > 0) ? -Math.floor(testData) - 1 : -Math.ceil(testData) - 1 : -1;
        // ~~
        var testData2 = 2.1;
        var testResult2 = (typeof testData === "number" && !isNaN(testData) && testData !== Infinity) ? (testData > 0) ? Math.floor(testData) : Math.ceil(testData) : 0;

    </script>
?