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>
 

你可能感兴趣的:(JavaScript)