JS的这些小程序你都会了吗

2019-10-31  本文已影响0人  倚剑闯天涯_

1)  var a;

var b = a * 0;

if (b == b) {

          console.log(b * 2 + "2" - 0 + 4);

} else {

          console.log(!b * 2 + "2" - 0 + 4);

}

答案:26

2) <script>

        var a = 1;

</script>

<script>

var a;

var b = a * 0;

if (b == b) {

        console.log(b * 2 + "2" - 0 + 4);

} else {

        console.log(!b * 2 + "2" - 0 + 4);

}

</script>

答案:6

3)  var t = 10;

function test(t){

       var t = t++;

}test(t);

console.log(t);

答案:10

4) var t = 10;

function test(test){

      var t = test++;

}test(t);

console.log(t);

答案:10

6) var t = 10;

function test(test){

       t = test++;

}test(t);

console.log(t);

答案:10

7) var t = 10;

function test(test){

      t = t + test;

      console.log(t);

      var t = 3;

}test(t);

console.log(t);

答案:NaN  10

8) var a;

var b = a / 0;

if (b == b) {

        console.log(b * 2 + "2" - 0 + 4);

} else {

        console.log(!b * 2 + "2" - 0 + 4);

}

答案:26

9)<script>

      var a = 1;

</script>

<script>

    var a;

    var b = a / 0;

    if (b == b) {

        console.log(b * 2 + "2" + 4);

    } else {

        console.log(!b * 2 + "2" + 4);

    }

</script>

答案:Infinity24

上一篇 下一篇

猜你喜欢

热点阅读