javascript2

代码变化一:
<script> function abs(){ var x; if(x>0){ return x; } else{ return -x; } } console.log(abs(-9));// NaN </script>
代码变化二:
<script> function abs(x){ //var x; if(x>0){ return x; } else{ return -x; } } console.log(abs(-9));// 9 </script>
代码变化三:
<script> function abs(){ //var x; if(x>0){ return x; } else{ return -x; } } console.log(abs(-9));// ReferenceError: x is not defined if(x>0){ </script>
代码变化四:
<script> function abs(){ //var x; if(x>0){ return x; } else{ return -x; } } console.log(x=-9);// -9 </script>
代码变化五:
<script> function abs(x){ //var x; if(x>0){ return x; } else{ return -x; } } console.log(x=-9);// -9 </script>
代码变化六:
<script>
    function abs(x){
        //var x;
        if(x>0){
            return x;
        }
        else{
            return -x;
        }

    }
    abs(-9);
    console.log(x=-9);//  -9
    </script>

 

posted @ 2015-01-09 10:35  净静竞——小晴  阅读(126)  评论(0编辑  收藏  举报