标签:
代码变化一:
<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>
标签:
原文地址:http://www.cnblogs.com/xl900912/p/4212710.html